在 ENTER 上提交表单按 int EXT js

far*_*ouk 0 extjs

我对 EXT.js 很陌生;我需要在按下 ENTER 时提交表单 下面是我的代码,但我不知道在密码字段的侦听器中调用什么 这是我的代码:即:在侦听器中调用的函数是什么

 <script type="text/javascript">
    Ext.onReady(function() {
        Ext.tip.QuickTipManager.init();

        Ext.create("Ext.container.Viewport", {
            layout: "border",
            rtl: <spring:theme code='theme.rtl' text='false' />
        });


        Ext.create("Ext.window.Window", {
            title: "<spring:message code='title.login' text='Login' />",
            height: 310,
            width: 450,
            closable: false,
            layout: "border",
            items: [{
                    xtype: "panel",
                    border: false,
                    bodyCls: "login-header",
                    height: 160,
                    region: "north"
                }, {
                    id: "<%=loginFormId%>",
                    url: "<spring:url value='/secure/auth'/>",
                    xtype: "form",
                    layout: "form",
                    region: "center",
                    bodyPadding: 10,
                    border: false,
                    buttons: [{
                            handler: function() {
                                var form = this.up("form").getForm();
                                if (form.isValid()) {
                                    Ext.getCmp("<%=submitBtnId%>").disable();
                                    form.standardSubmit = true;
                                    form.method = "POST";
                                    form.submit();

                                }
                            },
                            id: "<%=submitBtnId%>",
                            text: "<spring:message code='button.submit' text='Submit' />"
                        }, {
                            handler: function() {
                                var form = this.up("form").getForm();
                                form.reset();
                            },
                            id: "<%=clearBtnId%>",
                            text: "<spring:message code='button.clear' text='Clear' />"
                        }],

                    defaultType: "textfield",
                    defaults: {
                        msgTarget: "side",
                        labelWidth: 100
                    },

                    items: [{
                            fieldLabel: "<spring:message code='input.username' text='Username' />",
                            name: "selfcare_username"
                        }, {
                            fieldLabel: "<spring:message code='input.password' text='Password' />",
                            name: "selfcare_password",
                            enableKeyEvents:true,
                            inputType: "password",
                            listeners: {
                                scope: this,
                                specialkey: function(f, e) {
                                    if (e.getKey() === e.ENTER) {

                                    }
                                }
                            }

                        }]
                }]
        }).show();

    <c:if test="${not empty param.error}">
        var errorMsg = "<c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}" />";
        if (errorMsg !== "") {
            Ext.MessageBox.show({
                title: "<spring:message code='title.error' text='Error' />",
                msg: errorMsg,
                closable: false,
                buttons: Ext.Msg.OK
            });
        }
    </c:if>
    });
</script>
Run Code Online (Sandbox Code Playgroud)

Wes*_*ant 5

现在最好使用表单上的 defaultButton 属性来指定表单上的默认按钮。这是处理程序将处理您的 ENTER 键的按钮。:

http://docs.sencha.com/extjs/6.0/6.0.2-classic/#!/api/Ext.panel.Panel-cfg-defaultButton