onclick

Hi

how do i determent between to items in the menu, with defrent onclick attachevent

example

when i go file> Reload it runs both onclick functions.

				var menu = a.attachMenu("dhx_web");
					menu.setIconsPath('./imgs/');
					
					menu.addNewSibling(null, "view", "View", false);
					menu.addNewChild("view", 0, "hide_tree", "Hide Tree", false, "ar_left_abs_dis.gif");
					menu.attachEvent("onClick",  function alert_t(){ alert('hello');} );
					menu.setHotKey("hide_tree", "Ctrl+H"); // setting a hotkey to a button
					menu.addNewSeparator("hide_tree");
					menu.addNewSeparator("view");
					
					menu.addNewSibling(null, "file", "File", false);
					menu.addNewChild("file", 0, "Reload", "Reload", false, "reload.png");
					menu.attachEvent("onClick", function reload(){
																	tree_1.deleteChildItems(0);
																	tree_1.loadXML('./data/tree8.php');
										} );
                                        menu.setHotKey("Reload", "Ctrl+R"); // setting a hotkey to a button
					menu.addNewSeparator("Reload");
					menu.addNewSeparator("file");

Hi
But i see just one ‘onClick’ declaration here…
Not enough data. Could you provide completed demo ti test it?
docs.dhtmlx.com/doku.php?id=othe … leted_demo

Hi

thank you very much

here is the demo file

hope it is ok

i marked the 2 onclicks in the code of index.php
htmlx Demo.zip (1.1 MB)

Now it’s clear.
You need to use the next check:

menu.attachEvent("onClick", function(id, zoneId, casState){ if(id=="view"){alert_t()} if(id=="file"){reload()} });

AAAAAA thank you very much.

You are welcome! :slight_smile: