PDA

View Full Version : How to make Enter Key as a Tab key in form panel



adms
21 Nov 2010, 12:52 AM
Hi,I want to use a 'tabindex' property for afield in my form panel to navigate to the next field when I press 'enter' key. i want the 'enter' key behaves like a tab key in my form panel to navigate between form fields.

thanks:)

jay@moduscreate.com
25 Nov 2010, 4:55 PM
Why do you want to break a known "enter to submit" user interaction paradigm?

adms
26 Nov 2010, 11:21 PM
because I have 'textfield' field acts as a key for the form. when the value is changed in the key field an ajax will be called with parameter of the value in the textfield to fill other fields in the form.the 'onchange' event fires when a tab key is pressed .i want also the enter key to act as tab key to fire the onchange event in order to call the ajax.
thanks

Condor
26 Nov 2010, 11:44 PM
You can quite easility catch the enter key in the keypress and/or keydown event, but focussing the next component, like tab does, is a bit tricky (you first have to find the component base on both the tabIndex and the DOM order).

devtig
27 Nov 2010, 1:02 AM
You don't need to mimic tab key. Just make your ajax call on change and on specialkey on your key field.

adms
29 Nov 2010, 6:13 AM
thanks for response
i tried this code:
note: mykeyfield is a trigger field.


mykeyfield.on('keydown',function(keyfield,e){
if(e.ENTER){
var nextfld = keyfield.nextSibling();
nextfld.focus();
}
}

by this code, after pressing 'entrer' the cursor is moved to the next field and focused.
but the keyfield is still focused also ,and the blur event for the keyfield not fired why????