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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -