Javascript 为什么我的ExtJS表单没有提交?
我使用ExtJS弹出一个带有简单编辑表单的窗口,但按下submit按钮时,没有进行XHR调用,我在控制台中得到一个Javascript 为什么我的ExtJS表单没有提交?,javascript,extjs,submit,Javascript,Extjs,Submit,我使用ExtJS弹出一个带有简单编辑表单的窗口,但按下submit按钮时,没有进行XHR调用,我在控制台中得到一个this.form.el.dom未定义的错误报告 这是我的密码: var myNameSpace = new function(){ var editForm, editWindow; this.init = function(){ Ext.Ajax.request({ url: '/server/action.php',
this.form.el.dom未定义的错误报告
这是我的密码:
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();
});
任何关于这一主题的观点都将受到极大的赞赏,并将获得大量的支持。我要说的是,这个问题是表单submital的异步性质。表单在收到来自Ajax提交事件的响应之前关闭。尝试将您的editWindow.close()
行移动到成功处理块中。同样的事情也发生在我身上。