Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha touch 2- Ext.dispatch replacement?

What is the replacement for sencha touch 1.1 Ext.dispatch method in sencha touch 2?

I need replacement for code below

listeners:{
    itemtap:function(data,index){
        var record = data.getStore().getAt(index);
         // the record that has been clicked.
         Ext.dispatch({
            controller: 'ControllerName'
            ,action: 'ControllerMethod'
            ,record: record
        });
    }
}
like image 699
Pravin Avatar asked Nov 07 '11 05:11

Pravin


3 Answers

In sencha touch 2.0 to get the controller instances from anywhere use

<your app name>.app.getController('your controller name');

where your application name is setup in app.js

like image 180
railwayparade Avatar answered Oct 20 '22 00:10

railwayparade


Method Ext.dispatch still exists in Sencha Touch 2: http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Application-method-dispatch

But if you just don't like to use it for some reason, you can get an instance of the controller and call method dicrectly:

Ext.ControllerManager.get('ControllerName').ControllerMethod({record: record});
like image 34
Pavel Podlipensky Avatar answered Oct 19 '22 23:10

Pavel Podlipensky


Try this, it should work:

window['AppName'].app.getController('ControllerName').MethodName(Args)

Or, alternatively:

window['AppName'].app.dispatch({
    controller: 'ControllerName',
    action: 'MethodName',
    args:ArgsArray
}
like image 37
Boopathi Raja K Avatar answered Oct 20 '22 01:10

Boopathi Raja K