View Full Version : passing parameters via handler?

30 Apr 2007, 8:50 AM
I'm attempting to confirm a menu action prior to execution however when I pass the function with parameters in the menu handler, the function executes on load instead of when the menu is selected. If I pass no parameters (handler: confirmproxy, ...etc..), it functions normally but fails in its intended purpose.

Is there a better way / syntax for doing this?

... menu item code....
handler: confirmproxy("Restore File","Are you sure you want to overwrite the current version?",this.getEl, restoreFile),
....etc etc....

function confirmproxy(ttext, stext, caller, fn) {
return Ext.MessageBox.show({
title: ttext,
msg: stext,
buttons: Ext.MessageBox.OKCANCEL,
animEl: caller

30 Apr 2007, 9:10 AM
This has been covered many times - see this thread (http://extjs.com/forum/showthread.php?t=4395) and/or Function createDelegate doc

30 Apr 2007, 9:22 AM
Thanks Tim,
In your example, can you explain what is being passed here (item, e, args)

Is createDelegate documented somewhere?

menu: {
id: 'basicMenu',
items: [
{text: 'An item',
handler: clickHandler.createDelegate(this, ['one'], true)
{text: 'Another item',
handler: clickHandler.createDelegate(this, [{foo:'two', bar:2}], true);

clickHandler: function(item, e, args)


30 Apr 2007, 9:38 AM
nevermind I got it... still would like to know if/where I can read up on createDelegate.

Thanks again.

30 Apr 2007, 9:40 AM
As I said it's doc'd in Function (http://extjs.com/deploy/ext/docs/output/Function.html#createDelegate)

The args passed are the base args for the event you're dealing with (click in this case) plus whatever else you pass in the array.