0

I'm using Daniel Buchner's Sidebar library.
- https://builder.addons.mozilla.org/package/25177/latest/

Is it possible for the addon to communicate with the sidebar.

/*** main.js ***/

var sidebarPanel = require('sidebar')sidebar({
    header: false,
    width:'200px',
    url: data.url('panel.html'),
    onDomReady: function(){
        this.injectAssets({
            css: [data.url('panel.css')],
            js: [data.url('panel.js')]
        });
    }
});
sidebarPanel.port.on('msg', function(sidebarmessage){
    console.log(sidebarmessage);
});
sidebarPanel.port.emit('msg', 'hello sidebar');


/*** panel.js ***/

self.port.on('msg', function(addonmessage){
    console.log(addonmessage);
});
self.port.emit('msg', 'hello addon');

I have read the "using port" docs but cannot figure out a solution. https://addons.mozilla.org/en-US/developers/docs/sdk/1.12/dev-guide/guides/content-scripts/using-port.html

I tried to modify the page-mod example for using port but was unsuccessful. Any help here would be appreciated.

1 Answer 1

0

The sidebar module you linked to is not an official SDK api and ( now that I look at the code ) does not feature the typical SDK pattern of being able to comunicate via async message-passing. In it's current state, it just isn't capable of doing that.

1
  • Thanks, I noticed this but thought there may be an easy workaround. Instead of trying to attach a content script and communicate with it, I've created a modified version of the library and I will use it's methods to manipulate the content of the sidebar. Not the best solution but I'll change it when/if they decide to add sidebar as an official api module. Dec 29, 2012 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.