-
27 Apr 2011 10:51 AM #1
Form submit on Enter
Form submit on Enter
Bros,
In Extjs 4, the Enter key to submit form that used to work in extjs 3 is no longer working.
I read through the API documentation and try to google but cannot find the solution. Please help.Code:keys: [{ key: Ext.EventObject.ENTER, fn: onSubmit }],
-
28 Apr 2011 5:21 AM #2
I couldn't get the "keys" config to work in Ex4 either. This works, though - in "afterRender" :
Code:this.keyNav = Ext.create('Ext.util.KeyNav', this.el, { enter: this.onSubmitButton, scope: this });
-
23 May 2011 5:10 AM #3
Was there a solution for capturing the Enter key? I am trying to implement this in the login example where I would like the enter key to submit the form. Is the "afterRender" event on the form?
Thank you.
-
23 May 2011 5:34 AM #4
I implemented it this way according to another post. For each field I added a listener:
The submitLogin() call is the same one the login button calls.Code:listeners: { specialkey: function(field, e){ if (e.getKey() == e.ENTER) { submitLogin(); } } },
-
24 May 2011 11:45 PM #5
MVC way
MVC way
Or, if you use MVC architecture in your application you can add this code to your controller
PHP Code:init: function() {
this.control({
'textfield': {
specialkey: function(field, e) {
if(e.getKey() == e.ENTER) {
field.up('form').getForm().submit();
}
}
}
});
}
-
8 Jun 2011 10:23 AM #6
listeners: {
specialkey: function(field, e){
if (e.getKey() == e.ENTER) {
submitLogin();
}
}
},
This worked for me. Thanks
-
8 Sep 2011 3:53 AM #7
In each field - isn't it horrible?
This works with the form and fnLogin as login function:
Code:listeners: { afterRender: function(thisForm, options){ this.keyNav = Ext.create('Ext.util.KeyNav', this.el, { enter: fnLogin, scope: this }); } }
-
24 Oct 2011 6:48 PM #8
I use the defaults property of the form to apply that single listener to all the fields (without having to write it out each time)
-
7 Dec 2011 10:01 AM #9
-
29 Jan 2013 12:38 AM #10
i think this is the best way ...i having a problem on my submitLogin(); function be cause my login function accepts a button as an angument
submitLogin(button);........so how can i pass any button?on a key press
Similar Threads
-
Form submit on Enter
By egorfine in forum Ext: DiscussionReplies: 3Last Post: 13 Apr 2011, 11:02 AM -
Submit Form with Enter
By drieraf in forum Ext 2.x: Help & DiscussionReplies: 14Last Post: 28 Apr 2010, 4:19 AM -
How to submit a form using the enter key?could anybody please help
By misra123 in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 2 Sep 2008, 1:10 AM -
i want Enter key submit my form
By mnask in forum Ext 2.x: Help & DiscussionReplies: 10Last Post: 3 Jul 2008, 1:03 AM -
Form without submit button, handling submit with shift+enter...
By violinista in forum Ext 1.x: Help & DiscussionReplies: 4Last Post: 5 Jun 2007, 12:02 AM


Reply With Quote
