0

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

  • Well this code looks the same as [here](http://stackoverflow.com/questions/16413033/how-to-call-a-method-from-controller-in-extjs/16413289?noredirect=1#comment23532901_16413289)... Anyway you will find your answer there – sra May 07 '13 at 07:22
  • yah i have chcked :-) thnks –  May 07 '13 at 07:32

1 Answers1

1

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);
}
Stephen Tremaine
  • 934
  • 6
  • 15