Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Gavin Mcphee on Jan 11, 2009 07:49
open dhtmlx forum
attachEvent XML toolbar

Am trying to attach an event to a button on my toolbar which is loaded from xml the problem is the function run no matter what button i press i can't appear to attach it to just one element of the bar. could some please give me some advice
Answer posted by Support on Jan 12, 2009 02:28
Toolbar sending button id to the event handler.

For example you have the following xml:

<?xml version="1.0"?>
<toolbar>
    <item id="new" type="button" img="new.gif"/>
    <item id="save" type="button" img="save.gif"/>
    <item id="open" type="button" img="open.gif"/>
        ...

Then attach an event to the toolbar:

toolbar.attachEvent("onClick", function(id){
    if (id == "new") {
        // button new was pressed
    }
    if (id == "save") {
        // button save was pressed
    }
    if (id == "open") {
        // button open was pressed
    }
});