问题
I'm making a Jetpack extension in which a widget opens a panel. Clicking the widget opens the panel as expected (anchored in the lower-right corner to the widget). But if I call widget.panel.show() from my code, the panel opens detached from the widget, centered in the screen, floating in space.
In short, how can I fix this?
Can I simulate a click event on the widget (somehow) instead of calling widget.panel.show()?
Can I force the panel to anchor to the widget?
This question has a solution that worked in the previous Jetpack API, but I can't translate to the new interface: Using positioning 'Panel' in new Jetpack API
回答1:
panel.show(require("tab-browser").activeTab.ownerDocument.getElementById('widget:yourAddonId@package.json-yourWidgetId'));
Works for me with Addon SDK 1.8.1
Where:
yourAddonId@package.json - your addon id from package.json
yourWidgetId - your widget id
回答2:
panel.show(widget)
isn't working?
来源:https://stackoverflow.com/questions/5478434/mozilla-jetpack-add-on-anchor-panel-to-widget