1
私は、成功と失敗のコールバックを提出することを、私は、フォームを持っている:フォームの提出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のExtJs4ですばらしいことですが、フォームは必要に応じて送信されますが、成功と失敗のコールバックはもう呼び出されません。これはまだ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