Reputation: 32269
I defined a html filed for the content of my panel, which is in data folder.
var popupPanel = require("sdk/panel").Panel({
contentURL: data.url("main.html")
});
I'm trying to access the DOM of this document, from a javascript, which is in lib folder. Seems to be not possible, since document variable is undefined.
Then I followed one of the sample add ons, where there's html and javascript in the data folder, and this javascript accesses the DOM of the html. I tried to follow this example, but differently than in this sample, I also have to call a webservice, and modify the DOM using the response. I found that I can't call webservices from the javascripts stored in data folder.
I read something about implementing communication between files in lib and data folder - but this is a very simple use case and I hope that there's a simpler solution, like, just putting the workflow in a single JS file :D (In Chrome it's possible!).
Note: I'm not asking how to call the webservice, already got that working. My only problem is how do I do that + access the DOM on the response.
Any ideas? Thanks in advance.
Upvotes: 0
Views: 140
Reputation: 33192
To quote the SDK panel documentation:
You can't directly access your panel's content from your main add-on code. To access the panel's content, you need to load a script into the panel. In the SDK these scripts are called "content scripts" because they're explicitly used for interacting with web content.
While content scripts can access the content they're attached to, they can't use the SDK's APIs. So implementing a complete solution usually means you have to send messages between the content script and the main add-on code.
Upvotes: 1