开发者

how to access a non-global variable in ext js 4.0.0

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.Pane开发者_开发技巧l)


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜