PDA

View Full Version : passing parameter to a handler



ByteLess
17 Aug 2012, 10:01 AM
here is my code

this.launcher.menu.items.push({ //text: 'Window '+(++windowIndex),
text: '#functionName#',

iconCls:'<cfoutput>#url.mc#</cfoutput>Class',
handler : this.createWindow,
scope: this,
windowId: windowIndex
//autoLoad: '<cfoutput>#functionLink#</cfoutput>'
});

how do I pass the parameter to createWindow.

I tried following and didn't work


handler : this.createWindow(this,['<cfoutput>#functionLink#</cfoutput>']),

error:

TypeError: this.app is undefined

vietits
17 Aug 2012, 6:05 PM
Hope this will help:


this.launcher.menu.items.push({
//text: 'Window '+(++windowIndex),
text: '#functionName#',
iconCls:'<cfoutput>#url.mc#</cfoutput>Class',
//handler: this.createWindow,
handler: function(){
return this.createWindow(this,['<cfoutput>#functionLink#</cfoutput>']);
},
scope: this,
windowId: windowIndex
//autoLoad: '<cfoutput>#functionLink#</cfoutput>'
});

slemmon
17 Aug 2012, 6:07 PM
handler: function () {
// this will now refer to the owner of the handler so you'll have to set up
// a reference to your original 'this' above somewhere (i.e. me = this)
me.createWindow(someParamHere);
}

ByteLess
20 Aug 2012, 5:45 AM
thank you very much, both options worked.