Board Logo

Passing custom variable(s) into event handler
tigra - 12/4/2003 at 09:11 PM

As you probably know with Tigra Tree Menu PRO you can assign event handlers globally to all tree items or to some tree items.

When assigning the handler in template or items file you only specify the name of function. When called, this function will receive single parameter: tree item object reference. Now if you want to pass some more parameters to the handler (for example application specific item ID) you can use item scope settings array. Just specify some key not currently used by the script:

['Home', 'http://www.softcomplex.com/',{'ho':'OnItemOpenHandler', 'myID': 35}]

In handler function the value can be acessed via tree item object reference:

function OnItemOpenHandler (o_item) {
if (o_item.a_config[2] && o_item.a_config[2]['myID']) {
var n_myID = o_item.a_config[2]['myID'];
// now you've got the value
}
...
}

to make items structure more compact and easy maintainable you can assign handler globally to all items while in event handler perform action(s) only for those items that have particular parameter defined.


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/