DHTMLX Docs & Samples Explorer

Event Handling In Case Of Single Loading


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>
<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.attachEvent("onShow", menuShow);
    menu.attachEvent("onHide", menuHide);
    menu.loadXML("../common/dhxmenu.xml?e=" + new Date().getTime(), function() {
        document.getElementById("ta").innerHTML += "<b>doOnLoad</b> onLoadFunction was called<br>";
    });
}
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>");
    return true;
}
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>");
}
function menuShow(parentId) {
    printLog("<b>onShow</b> Menu was shown, parentId <b>" + parentId + "</b><br>");
}
function menuHide(parentId) {
    printLog("<b>onHdie</b> Menu was hidden, parentId <b>" + parentId + "</b><br>");
}
</script>