1
我有一个表格,我的成功和失败回调提交:表单提交的ExtJS的6
的观点:
Ext.define('App.view.CommentForm', {
extend: 'Ext.form.Panel',
alias: 'widget.ship-commentForm',
url: 'addcomment.php',
items: [{
xtype: 'textarea',
fieldLabel: 'Comment',
name: 'text',
allowBlank: false,
maxLength: 1000
},{
xtype: 'textfield',
fieldLabel: 'User name',
name: 'username',
readOnly: true
}],
fbar: [{
text: 'Save',
formBind: true,
itemId: 'submit'
}]
})
而且控制器:
Ext.define('App.controller.MyController', {
init: function(){
this.control({
'ship-commentForm button#submit': {click: this.onFormSubmit},
...
onFormSubmit: function(btn){
var form = btn.up('form').getForm(),
me = this,
values = form.getValues();
form.submit({
success: function(form, action){
console.log('success')
},
failure: function(form, action){
console.log('failure')
}
})
setTimeout(function(){btn.up('window').close()}, 100)
},
虽然这个工作在ExtJs4中很好,在ExtJs6中,表单提交它应该,但成功和失败的回调不再被调用。这应该仍然符合the documentation of submit()
。
N.B.在服务器响应包含一个有效的JSON字符串:
{"success":true,"msg":"Comment saved"}
编辑:我刚刚加入,我怀疑是这个问题的控制器代码: setTimeout(btn.up('window').close(), 100)
我已经做了样品小提琴来测试您的问题,它是在我的小提琴https://fiddle.sencha.com/#view/editor&fiddle/1qjr –
@SuryaPrakashTumma由于工作的罚款。我也设法在短短的几分钟内让它在https://fiddle.sencha.com/#view/editor&fiddle/1qjq小提琴中工作。我还不确定问题出在哪里。 –
在form.submit的成功回调中调用'.close()'方法不是一个好主意吗?或者这是某种要求? – qmateub