2014-03-06 26 views
0

我對EXT.js非常陌生;我需要提交以下表單,當按下ENTER是我的代碼,但我不知道在這裏的密碼字段的聽衆叫什麼是我的代碼:即:什麼是監聽器調用函數在ENTER上提交表單按int EXT js

<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> 
}); 

回答

0

這是做聽衆:

listeners: { 
           keypress: function(textfield, e, options) { 
            if (e.keyCode === 13) { 
             var form = this.up("form").getForm(); 
             if (form.isValid()) { 
              Ext.getCmp("<%=submitBtnId%>").disable(); 
              form.standardSubmit = true; 
              form.method = "POST"; 
              form.submit(); 

             } 
            } 
           } 
          } 
相關問題