简体   繁体   中英

How to get Current Operating form in EXT JS

I have a request to submit a form on a press of ENTER button . I would like to customise it in such a way that it can be used anywhere throughout my application. So whenever i press enter after entering a field value. i can submit the current form. Is there a way to fetch the current form (without knowing form name or id) whenever a ENTER button is pressed on a particular field?

Ext.define('MyApp.overrides.Field',{
    override: 'Ext.form.field.Base',
    enableKeyEvents: true,
    listeners: {
        keyup: function(field, e) {
            var key = e.getKey(),
            if(key == 13) { // 13 = Enter key
                var form = field.up('form');
                if(form) form.submit();
            }
        }
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM