What's the best way to be notified when an extension's toolbaritem is being used?
-
10-10-2019 - |
Pergunta
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?
Solução
Have a look at Broadcasters and Observers. I think this will help you.
Outras dicas
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.