0

extjs のアプリケーションにコントローラーがあります。私はそのコントローラーにメソッドを持っています。それは何らかのアクションを実行しています。今、そのメソッドから別のメソッドを呼び出さなければなりません。コード....

 afterChartLayout: function(){
    if(this.initializedEvents==true) return;
    this.initializedEvents=true;
    Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){

        alert(obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count']);

    });

誰か助けてください...

4

1 に答える 1

1

Ext.Component.on 関数の 3 番目のパラメーターは、オプションのスコープ パラメーターです。そこに「this」キーワードを挿入すると、コールバック関数のスコープが維持されます。次のようになります。

afterChartLayout: function(){
    if(this.initializedEvents==true) return;
    this.initializedEvents=true;
    Ext.getCmp('barColumnChart').series.items[0].on('itemmousedown',function(obj){

        alert(obj.storeItem.data['source']+ ' &' + obj.storeItem.data['count']);
        //Call other function on the controller
        this.otherControllerFunction('paramOne');
        //Make sure to include "this" on the next line!!
    }, this);
}
于 2013-05-07T14:47:58.667 に答える