I am developing a FireFox extension using JPM Addon. I am loading a panel from the main index.js file like so...
var panel = require('sdk/panel');
var panel = panel.Panel({
contentURL: url('pages/popup.html'),
onHide: doHide
});
//and in another place...
panel.show({
position: button
});
The pages/popup.html file references a javascript file and I use the relative path to load it. I need to figure out how to pass a message from this javascript file, loaded by the panel web page, to the main index.js script file of the addon.
I tried postMessage as well as port.emit...
So, either
//index.js
panel = require("sdk/panel").Panel({
onMessage: function(message) {
console.log(message);
}
});
//popup.js - panel file
panel.postMessage('something');
...or...
//index.js
panel.on("message", function(text) {
console.log(text);
});
//popup.js
self.port.emit('message', 'hello world');
However, both of these don't seem to work. Help!