Reputation: 1
i defined a variable in the handler of a button and now want to access it in a different element in the same panel(Ext.grid.Panel)
Upvotes: 0
Views: 403
Reputation: 15099
If this variable is going to be accessed quite regularly then you could do something like this:
var panel = new Ext.grid.Panel({
title : 'Example'
//other config
myVariable : 0 //default value,
buttons : [{
text : 'save'
handler : function(){
panel.myVariable = 100;
panel.hide();
}
}],
listeners : {
hide : function(){
console.log(this.myVariable); //will print 100
}
}
});
Upvotes: 1
Reputation: 2387
You can not access that local variable from any other scope. Save that variable in your panel scope or in scope that is visible from both places (handler and other). Write your code and I'll give you more detailed advise.
Upvotes: 3