Friday, October 5, 2012

EXTJS Submit Form on Enter Key Press

Mostly there is a requirement to submit the form data when  the user hits the enter key instead of clicking on the submit button. This can be achieved:

EXTJS4:

                            listeners: {
                                afterRender: function(thisForm, options){
                                    this.keyNav = Ext.create('Ext.util.KeyNav', this.el, {
                                        enter: processLogin,
                                        scope: this
                                    });
                                }

EXTJS3:
                        keys: {
                                key: Ext.EventObject.ENTER,
                                fn: processLogin,
                                scope:this
                            }

2 comments: