menu onClick is not working

Hi
I am using Menu version3.0.When i am clicking on Menu Item menu click event not firing.

Code:
var myLayout, myTree, myGrid, myFolders, myMenu, myToolbar;
var gl_view_type = “dlist”;
var gl_view_bg = “”;
function doOnLoad() {
myLayout = new dhtmlXLayoutObject(document.body, “1c”);
myMenu = new dhtmlXMenuObject(“menuObj”, “dhx_black”);
myMenu = myLayout.cells(“a”).attachMenu();
myLayout.attachHeader(“my_logo”);
myLayout.attachFooter(“my_copy”);
myLayout.cells(“a”).hideHeader();
myMenu.setIconsPath(“common/imgs/”);
myMenu.setOpenMode(“web”);
myMenu.attachEvent(“onClick”, function (id) {
var url = myMenu.getUserData(itemd, “www.msn.com”);
myLayout.cells(“a”).attachURL(url)
});
myMenu.loadXML(“common/dhxmenu.xml?=id”, function () {
});
}

My xml format

xyz.aspx

Please help me.

Thanks
Asif

Hi
Please, see the sample: dhtmlx.com/docs/products/dht … hrefs.html
You need to modify your XML

Hi
Thanks for quick reply but if you see sample link what you provided in your response. it’s opening url in new window.I want to open links in same window inside layout.
one more thing menu OnClick event is not working even i added alert(‘Test’) that also not coming.
Please let me what is the issue.

Thanks
Asif

But in general ‘onClick’ works:
dhtmlx.com/docs/products/dht … e_cas.html
See in your suit locally: dhtmlxMenu/samples/05_events/04_events_single_cas.html

About layout cell target i answered you here:
viewtopic.php?f=4&t=24060

Hi,
I using that sample for reference but when i am using in my application it’s not working.
atleast it should open alert window.it’s not opening.
please find my code for reference.

Thanks
Asif
ForReferenceCode.zip (1.25 KB)

Hi
Replace in this line:
myMenu.attachEvent(“onClick”, function (id, zoneId, casState) { alert(menu.getItemText(id)) });
menu to ‘myMenu’ or ‘this’ - alert will arise

Hi,
Thanks for reply.I tried your code but still not working.I am using below code and it’s working for me.

myMenu.attachEvent(“onClick”, doOnClick());

function doOnClick() { myLayout.cells(“a”).attachURL(“LaunchAcs.aspx”);}

but if you see attachURL still hardcoded.
Now question is how to get dynamic url means when i click on menu item i should get URL.

if you see below code.we are passing id . how to pass id to above doOnClick() function.
// myMenu.attachEvent(“onClick”, function (id) {}

Thanks
Asif

In this line you need to declare function doOnClick(), not launch.
myMenu.attachEvent(“onClick”, doOnClick);
Therefore using double quotes in this case isn’t correct.

myMenu.attachEvent("onClick", doOnClick); function doOnClick() { myLayout.cells("a").attachURL("LaunchAcs.aspx");}

About ID: it is transferred as parameter in ‘onClick’ event by default

Hi,
As you told ID it is transferred as parameter in ‘onClick’ event by default but as you see i doOnClick function when i am doing alert it’s showing null or empty message.
myMenu.attachEvent(“onClick”, doOnClick());
function doOnClick() {
var url = “”;
alert(this.menu.getItemText(this.menu.id));
alert(this.menu.getUserData(this.menu.id, “url”));
myLayout.cells(“a”).attachURL(“LaunchAcs.aspx”);
}
please tell me how pass or get id of click menu item.

secondly if use below line it’s not firing click event
myMenu.attachEvent(“onClick”, doOnClick);
but if we use below way it’s firing click event.
myMenu.attachEvent(“onClick”, doOnClick());

Thanks
Asif

Hi
Do the next:
myMenu.attachEvent(“onClick”, doOnClick);
function doOnClick(id) {
var url = “”;
alert(this.getItemText(id));
alert(this.getUserData(id, “url”));
myLayout.cells(“a”).attachURL(“LaunchAcs.aspx”);
}
And pay attantion one more time on this:
docs.dhtmlx.com/doku.php?id=dhtm … ck_ontouch
dhtmlx.com/docs/products/dht … ingle.html