最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Sencha touch 2- Ext.dispatch replacement? - Stack Overflow

programmeradmin0浏览0评论

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
        });
    }
}

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
        });
    }
}
Share Improve this question edited Apr 25, 2012 at 11:50 Matthias 7,5216 gold badges57 silver badges90 bronze badges asked Nov 7, 2011 at 5:55 PravinPravin 6,6624 gold badges45 silver badges51 bronze badges 2
  • 1 Check this sencha.com/forum/showthread.php?151239-Ext.dispatch-replacement – ilija139 Commented Nov 8, 2011 at 2:06
  • Btw what has ruby on rails 3 to do with this question? :-) – ilija139 Commented Nov 8, 2011 at 2:08
Add a comment  | 

4 Answers 4

Reset to default 8

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

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});

Try this, it should work:

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

Or, alternatively:

window['AppName'].app.dispatch({
    controller: 'ControllerName',
    action: 'MethodName',
    args:ArgsArray
}

When the call shal be done from a controller, you'll have the application instance by getApplication method, there is a method getControllerInstance which returns an array.

this.getApplication().getControllerInstances()['yourcontrollername'].yourmethod(yourparams)
发布评论

评论列表(0)

  1. 暂无评论