把Tab键全部转换成Enter(回车)键

阅读更多
var run = function() {
    var all = Ext.query('input[type!=hidden]');
    Ext.each(all, function(o, i, all) {
                Ext.get(o).addKeyMap({
                    key : 13,
                    fn : function() {
                        try {
                            all[i + 1].focus()
                        } catch (e) {
                            event.keyCode = 9
                        }
                        if (all[i + 1]
                                && /button|reset|submit/.test(all[i + 1].type))
                            all[i + 1].click();

                        return true;
                    }
                })
            });
    Ext.getBody().focus();

    try {
        var el;
        if (typeof eval(xFocus) == 'object') {
            el = Ext.getDom(xFocus).tagName == 'input'
                    ? Ext.getDom(xFocus)
                    : Ext.get(xFocus).first('input', true);
        } else {
            el = all[xFocus || 0];
        }
        el.focus();
    } catch (e) {
    }
}
Ext.isReady ? run() : Ext.onReady(run);

你可能感兴趣的:(EXT)