problems with onClick url event handler for xml

Hi there,



First of all, thanks for this menu system, been looking for a decent xml based javascript menu for a long time!



I’m having some issues with the menu though. It renders out fine on the page but the onclick url event won’t work! Please help :slight_smile:



Here is my html code:



----------------------------------------------------







DHTMLX Menu Test































----------------------------------------------------



Here is my xml:



----------------------------------------------------





<item id=“Home” text="Home>index.html





----------------------------------------------------



What am I doing wrong?



Thanks,



Russell


Hello,


the issue wasn’t reproduced locally - the sample is attached.


But onclick isn’t called for complex items (when item has children). In order to enable onclick in this case you can modify the following line in the dhtmlxmenu.js, _doOnClick method:

if (type.charAt(0)==“c”) { return; } // can’t click on complex item
try to replace it with:
if (type.charAt(0)==“c”) {this.callEvent(“onClick”, [id]); return; } // can’t click on complex item






1248427189.zip (34 KB)

Thanks for this, I tried putting this in the js though and to no effect :-/

I am trying to make it so that the menu system can be used to navigate a website. Is this possible?

The menu loads up fine, but it still doesn’t go to the url link from my xml file when clicked. If I put the alert function from your sample in, it does pick up the url though and puts it in a popup alert window. I’m at a loss!

Thanks in advance.


What approach do you use open new window ?


The possible way is:


menu.attachEvent(“onClick”,function(id){


var url = menu.getUserData(id,“url”)


window.open(url);


});

Thanks!

This has almost worked now.

It opened the link in a new window/tab. How do I make it open in the same one? ie: the parent window

Cheers,

Russell

I think I’ve got it now, thanks for your help!

window.location.href=(url);

Thanks again :slight_smile: