I am dynamically generating a dhtmlxTree. I have 3 different node types. Depending on which kind of node you click, I want the context menu to reflect the appropriate menu items.
Right now, I attach to the onBeforeContextMenu event and check the prefix of the node ID for the node type. Then I load the appropriate menu xml file.
dhxTree.attachEvent("onBeforeContextMenu", getMenu);
The following is an example of menu_application.xml:
[code]<?xml version="1.0" encoding="UTF-8"?>
[/code]Here is menu_host.xml:
[code]<?xml version="1.0" encoding="UTF-8"?>
[/code]This is the function to choose the menu_*.xml:
function getMenu(id) {
dhxMenu.clearAll();
dhxMenu.loadXML("xml/menu_" + id.split(":")[0] + ".xml");
return true;
}
As you can imagine, although this works, it is not very responsive. I would prefer a way to preload each menu_*.xml file once and dynamically attach them to the appropriate nodes.
Does anyone have any advice for how to do this better?