2012-06-05 2 views
2

ExtJS를 사용하여 간단한 편집 양식으로 창을 팝업하고 있지만 제출 버튼을 누르면 XHR 호출이 이루어지지 않고 콘솔에 this.form.el.dom is undefined 오류가보고됩니다.왜 내 ExtJS 양식이 제출되지 않습니까?

var myNameSpace = new function(){ 
    var editForm, editWindow; 

    this.init = function(){ 

     Ext.Ajax.request({ 
      url: '/server/action.php', 
      success: function(result){ 
       console.log('ajax is working ok'); // I get this 
      } 
     }); 

     editForm = new Ext.form.FormPanel({ 
      width:450, 
      autoHeight: true, 
      header : false, 
      items: [{ 
       name: 'color', 
       fieldLabel: 'Color', 
       xtype: 'textfield', 
       value: 'blue' 
      }], 
      buttons: [{ 
       text:"Submit", 
       scope: this, // tried without this, too 
       handler: function(){ 
        // editForm.getForm().getValues() returns normal values 
        editForm.getForm().submit({ 
         url: '/server/action.php', 
         success: function(form, action) { 
          console.log('Yes! Success!'); // I don't get this 
         }, 
         failure: function(form, action) { 
          console.log('failed.'); // I don't get this 
         } 
        }); 
        editWindow.close(); // works 
        console.log('the form is now closed'); // I get this 
       } 
      }] 
     }); 

     editWindow = new Ext.Window(
     { 
      title:'Enter your color', 
      autoWidth: true, 
      autoHeight: true, 
      layout: 'fit', 
      modal: true, 
      items: editForm, 
      closeAction: 'hide' 
     }); 
     editWindow.show(); 
    }; 

}; 

Ext.onReady(function() { 
    myNameSpace.init(); 
}); 

주제에 어떤 빛이 크게 감사하고 무릎을 꿇고 서라도 upvoted :

여기 내 코드입니다.

답변

5

나는이 문제가 양식 잠수정의 비동기 적 성격이라고 말하고자합니다. 양식은 Ajax 제출 이벤트에서 응답을 받기 전에 종료됩니다. 성공 처리 블록 안에 editWindow.close() 행을 이동해보십시오.

+0

그게 전부 였어! 아주 좋은 통찰력. 고마워. –

+0

당신은 환영합니다 :) – dbrin

관련 문제