How To Properly Set Events For Dynamic Xul Elements?
I have a toolbar extension that generates dynamic toolbarbutton and menuitem elements. These items are typically constructed like this: tempMenuItem = document.createElement('menui
Solution 1:
Well, you obviously use addEventListener()
method as the suggestion says:
tempMenuItem.addEventListener("command", function(event)
{
myObject.someFunction();
}, false);
Or somewhat shorter if you also use the Function.bind()
method:
tempMenuItem.addEventListener("command", myObject.someFunction.bind(myObject), false);
Post a Comment for "How To Properly Set Events For Dynamic Xul Elements?"