View Full Version : passing extra parameter to .each
martin
13 Sep 2007, 6:35 PM
How would I go about adding an additional parameter to the function called with '.each' of a compositeElement?
I want to pass 'lvl' to the initMenu function:
var lvl = "testing";
var ds = ctxtObj.select(".ui-menu a", true).each(this.initMenu);
Any idea? Thanks...martin
hendricd
13 Sep 2007, 7:29 PM
Tried this?
var lvl = "testing";
var ds = ctxtObj.select(".ui-menu a", true).each(this.initMenu.createDelegate(this,[lvl],true));
martin
14 Sep 2007, 4:58 PM
I can't seem to get this to work. I'm getting the link clicked on as the new parameter instead of the 'level'....martin
Animal
14 Sep 2007, 10:08 PM
var ds = ctxtObj.select(".ui-menu a", true).each(this.initMenu.createDelegate(this,['testing'],true));
Passing true as the final parameter in createDelegate appends the specified parameter list, so there will be two parameters to the each callback function, the current object in the iteration, and 'testing'
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.