-
9 Oct 2012 3:27 AM #1
Answered: Can't access controller method after submit() success
Answered: Can't access controller method after submit() success
When the puchaseItem function is trigged off a submit button. The console says there is no method updatePageInfo(). Any ideas why? I assume I need to pass a scope somehow?
Code:Ext.define('test.controller.Main', { extend: 'Ext.app.Controller', config: { refs: { purchaseform: 'instorepurchaseform', }, control: { '#purchase_item': { tap: 'purchaseItem' } } }, updatePageInfo: function(sid, c_size) { console.log("here"); }, purchaseItem: function() { Ext.Msg.confirm('Confirm', 'Are you sure?', function(button) { if (button == 'yes') { var values = this.getPurchaseform().getValues(); this.getPurchaseform().submit({ success: function(form, result) { Ext.Msg.alert('Purchase successfully!', ""); this.updatePageInfo(values.sid, values.c_size); }, failure: function(form, result) { Ext.Msg.alert('Failed to purchase!', ""); } }, this); } }, this); } );What comes around goes around
-
Best Answer Posted by coletek
Cheers. The issue is the doco doesn't say that. It says (can you please explain how you determined how to set scope from the doco?):
submit( this, result, e, eOpts )PREVENTABLEFires upon successful (Ajax-based) form submission
This action following this event is preventable. When any of the listeners returns false, the action is cancelled.Available since: Touch 1
Parameters- this : Ext.form.PanelThis FormPanel
- result : ObjectThe result object as returned by the server
- e : Ext.EventObjectThe event object
- eOpts : ObjectThe options object passed to Ext.util.Observable.addListener.
- this : Ext.form.PanelThis FormPanel
-
9 Oct 2012 6:17 AM #2
scope problem.
I know you have tried to change the scope,but you used a wrong way.Read document about Form.submit()Code:this.getPurchaseform().submit({ success: function(form, result) { Ext.Msg.alert('Purchase successfully!', ""); //here 'this' is the formpanel. this.updatePageInfo(values.sid, values.c_size); }, failure: function(form, result) { Ext.Msg.alert('Failed to purchase!', ""); } }, this);
Code://this.getPurchaseform().submit({}, this); this.getPurchaseform().submit({ scope: this });I write English by translator.
-
10 Oct 2012 1:39 AM #3
Cheers. The issue is the doco doesn't say that. It says (can you please explain how you determined how to set scope from the doco?):
submit( this, result, e, eOpts )PREVENTABLEFires upon successful (Ajax-based) form submission
This action following this event is preventable. When any of the listeners returns false, the action is cancelled.Available since: Touch 1
Parameters- this : Ext.form.PanelThis FormPanel
- result : ObjectThe result object as returned by the server
- e : Ext.EventObjectThe event object
- eOpts : ObjectThe options object passed to Ext.util.Observable.addListener.
What comes around goes around
- this : Ext.form.PanelThis FormPanel


Reply With Quote