Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sanju Thomas on Nov 19, 2009 10:08
open dhtmlx forum
OnClick event is not fired from dhtmlXToolbarObject


OnClick event is not fired from dhtmlXToolbarObject. Am I missing something here ? My Code is given below.



<link rel="STYLESHEET" type="text/css" href="DHTMX-2\dhtmlxToolbar\codebase\skins\dhtmlxtoolbar_dhx_blue.css">

<script type="text/javascript" src="DHTMX-2\dhtmlxToolbar\codebase\dhtmlxcommon.js"></script>
<script type="text/javascript" src="DHTMX-2\dhtmlxToolbar\codebase\dhtmlxtoolbar.js"></script>


<SCRIPT LANGUAGE="JavaScript">

function init(){
    
     var toolbar = new dhtmlXToolbarObject("toolbarObj");
     toolbar.loadXMLString('<toolbar><item id="testItem" type="buttonTwoState" text="Test Item" selected="true"/></toolbar>');
     toolbar.attachEvent("onClick", function(id){
     alert("Button "+id+" was clicked");
     });
    
}

</SCRIPT>
<body onload="init();">

<div style="width:100px;height:25px;" id="toolbarObj"></div>

</body>
Answer posted by Alex (support) on Nov 20, 2009 02:37

Try use onStateChange event for two-state buttons :

toolbar.attachEvent("onStateChange", function(id,state){
  alert("Button "+id+" was clicked");
});

Answer posted on Nov 20, 2009 08:39
Thanks