user2262079
user2262079

Reputation:

How to to call a function from a function in ExtJs

i have a controller in my application in extjs. i have a method in that controller ,that is doing some action .Now i have to call another method from that method.But when i am doing that the previous method is not working please give me the way to call it appropriately .Here is my code....

 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']);

    });

somebody please help...

Upvotes: 0

Views: 3264

Answers (1)

Stephen Tremaine
Stephen Tremaine

Reputation: 954

The third parameter to the Ext.Component.on function is an optional scope parameter. If you insert the "this" keyword there, you will maintain scope in your callback function. Should go like 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);
}

Upvotes: 1

Related Questions