javascript - calling wrong method ExtJS -
i have piece of code :
listeners: { beforerender: function() { if (importbutton == true) { this.menu.add( { text: 'import', iconcls: 'importicon', listeners: { click: new ifauthorizing('import') } }) } this.menu.add( { text: 'consultation', iconcls: 'searchicon', listeners: { click: menuconsultation } }) } }
that supposed add items menu when conditions ok.
it's working, button added if conditions matches.
the problem coming
listeners: { click: new ifauthorizing('import') }
this listener supposed appended menu item, triggered during beforerender event of parent.
function ifauthorizing(arg) { console.log('import') }
the 'import' displayed in console logs during beforerender event, , if click on menu item supposed have click method, nothing happens.
i know why.
new ifauthorizing('import')
here operator new tries create object , interpretes ifauthorizing constructor. constructor called immediately, that's why fires on beforerender event. result object not copy of function ifauthorizing, can't called on menu item's event desired result.
Comments
Post a Comment