Self.port is undefined

Hi!
I am getting self.port is undefined error when working on FF plugin under JPM.
NodeJS is used.

The file.js script is under data and sends the message to the index.js, which have a panel. Self.port.emit is not working, but seem to work maybe once or several times.

myPanel.port.on(“click-link”, function(name) {
console.log(name);
});

function F()
{alert(name+“11”);
var x=name.toString();
self.port.emit(‘click-link’, x);
}

Are you using self.port from a regular javascript file? It has to be a contentScript inejcted into myPanel. Can you share he code you use to create myPanel?

Also by "NodeJS is used " do you mean you are using JPM?

Yes, JPM. Yes, contentScript is done. Thank you!

var self = require(“sdk/self”);

var myPanel = require(“sdk/panel”).Panel({
contentURL: self.data.url(“file.html”),
contentScriptFile: self.data.url(“file.js”),
contentScriptWhen: “ready”

});

myPanel.show();

myPanel.port.on(“click-link”, function(name) {
console.log(name);
});

It’s strange, but maybe 1-3 time it worked. Now not. Yesterday can be ok.

Wow this is weird. Thins look ok there to me. However, I’m not an SDK expert, maybe someone else can swoop in and check this out.

I am not sure what exactly your code is showing me.

First off, I am not sure how good of an idea it is to use alert()inside a panel. I assume F is bound as a click listener to a link?

I’d also recommend adding the listener before opening the panel, to be sure it’s actually attached when the panel loads.

Further you can start and end multi-line code-blocks with ``` and inline code with single back-ticks before and after it.

Thanks! It was for getting the code, yes.
All worked 2-3 times somehow, but later no. I decided to get without this.
Now I want to change the Date(), for getting another Timezone. It’s also a question. For this topic or not, if you can answer, please post.