extjs4 - How can I access class variables in an ExtJS event handler? -
this.geturl = 'test'; this.items.add( new ext.form.checkbox( { listeners: { check: function(checkbox, checked) { alert(this.geturl); }, } ) )
how access this.geturl
in check handler?
there multiple ways access property geturl
. here few possible options:
1. use ext.getcmp: if set id
formpanel (or other extjs component whatever using), can access using ext.getcmp()
method. so,
var yourcomponent = ext.getcmp('yourcomponentid'); alert(yourcomponent.geturl);
2. use ownerct property: if need access parent container (if parent holding checkbox) can access parent container through public property ownerct
.
3. use refowner property: if use ref
system in code, can make use of property hold of container , access required variable.
i think easy go first option.
Comments
Post a Comment