1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    144
    Answers
    19
    Vote Rating
    0
    coletek is on a distinguished road

      0  

    Default 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

  2. 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


  3. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    scope problem.
    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);
    I know you have tried to change the scope,but you used a wrong way.Read document about Form.submit()
    Code:
    //this.getPurchaseform().submit({}, this);
    
    this.getPurchaseform().submit({
        scope: this
    });
    I write English by translator.

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    144
    Answers
    19
    Vote Rating
    0
    coletek is on a distinguished road

      0  

    Default


    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

    What comes around goes around

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar