views:

30

answers:

2

I want to setup label attributes, and event listeners for a toolbaritem when it's being used. Because even though I add my extension's toolbaritem to <toolbarpalette id="BrowserToolbarPalette"> it is not found by document.getElementById unless it is being used. At the moment I have DOMNodeInserted event listeners on the navigation bar and add-on bar which sets up my toolbaritem's attributes, but I'm wondering if there is a better way?

A: 

Are you calling document.getElementById too early, possibly before Firefox has added the item into the toolbar? If so, you might want to move your code to a function which is registered to be called on the "load" event on the main browser window. This should ensure that the browser, including the toolbar, has been successfully built by the time your code runs.

Tim
The document.getElementById call is in a "load" event listener, the item dne and this appears to be because the user needs to customize the toolbar and add it.
Erik Vold
A: 

Have a look at Broadcasters and Observers. I think this will help you.

Felix Kling
I just read it, it doesn't appear to be helpful. It appears to describe how you can broadcast changes to multiple elements in a document, but I want to know when a toolbaritem is added to browser.xul, which seems to me to be a completely different problem.
Erik Vold