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