DHTMLX Docs & Samples Explorer

Event Handling In Case Of Dynamical Loading

* This sample requires PHP to work.

Source
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxmenu_dhx_skyblue.css">
<script src="../../codebase/dhtmlxcommon.js"></script>
<script src="../../codebase/dhtmlxmenu.js"></script>
<script src="../../codebase/ext/dhtmlxmenu_ext.js"></script>
 
<div style="height: 250px;"><div id="menuObj"></div></div>
* This sample requires PHP to work.
<div id="ta" style="width: 500px; height: 160px; border: #909090 1px solid; overflow: auto; font-size: 10px; font-family: Tahoma;"></div>
 
 
<br>
<script>
var menu;
function initMenu() {
    menu = new dhtmlXMenuObject("menuObj");
    menu.setIconsPath("../common/imgs/");
    menu.attachEvent("onXLS", menuXLS);
    menu.attachEvent("onXLE", menuXLE);
    menu.attachEvent("onClick", menuClick);
    menu.attachEvent("onTouch", menuTouch);
    menu.enableDynamicLoading("../common/dhtmlxmenu_dl.php");
}
function printLog(text) {
    document.getElementById("ta").innerHTML = text + document.getElementById("ta").innerHTML;
    document.getElementById("ta").scrollTop = 0;
}
function menuClick(id) {
    printLog("<b>onClick</b> Item " + menu.getItemText(id) + " (id:" + id + ") was clicked<br>");
}
function menuTouch(id) {
    printLog("<b>onTouch</b> Menu was touched at item " + menu.getItemText(id) + " (id:" + id + ")<br>");
}
function menuXLS() {
    printLog("<b>onXLS</b> XML loading has started<br>");
}
function menuXLE() {
    printLog("<b>onXLE</b> XML was loaded into menu<br>");
}
</script>