Sorry, I have little experience with Add-on Development and Javascript.
Therefore I think and hope, my question is a no-brainer to most of you.
I’m trying to access the properties of ui components without any success.
In one example I’m working with an array of sidebar workers.
From https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_sidebar I took this code:
var workerArray = [];
function attachWorker(worker) {
workerArray.push(worker);
console.log(worker.id);
}
function detachWorker(worker) {
var index = workerArray.indexOf(worker);
if(index != -1) {
workerArray.splice(index, 1);
}
}
var sidebar = require("sdk/ui/sidebar").Sidebar({
id: 'my-sidebar',
title: 'My Sidebar',
url: require("sdk/self").data.url("sidebar.html"),
onAttach: attachWorker,
onDetach: detachWorker
});
I have just added console.log(worker.id);
in the function attachWorker
.
The console shows, that the id is undefined.
This happens with all kind of workers, I was trying.
My goal is to find a worker in the workerArray
with its id
.
I think I’m having a fundamental lack of understanding, how this could be achieved.
Could you please give me a hint!