So I have a tree of items created using XUL. When I select item from this tree and click a View button I want to display information about the selected item. I do it as below but the button does not work at all.
Assign an id for the tree:
<tree id="assetList" flex="1" multiple="false">
Then I attach a function to the button:
<button id="view-button" align="right" class="dialog" label="View" oncommand="view()" />
Then I have function view written as bellow:
function view(){
var tree = document.getElementById("assetList");
var items = tree.selectedItems;
if(items.length == 0)
alert("No item was selected");
else if(items.length > 1)
alert("Please select one item at a time");
else{
txt = items.getAttribute('id'); //it's just for testing right now
alert(txt);
}
}
Even when I don't select anything and click view the alert message is not fired. What did I do wrong? and How can I fix it?
Thanks