I've added a new menu item to the context menu, which triggers a Javascript function to toggle a class on the main menu. What I'd like to do now is change the menu item text depending on the presence/absence of that class.
Given that the context menu is dynamically built on each request, changes I make to the context menu as part of the initial function are lost when it is destroyed. Also looks like the contextmenu event is supressed as adding an event handler doesn't work.
Is there any way I can either add a listener for right-clicking the menu items, or be notified when the context menu is open?
I'm assuming that it's a menu rendering on your public facing website you're talking about?
I don't know what your code looks like but you should be able to have the text for the different toggle states saved in data-* attributes so on an element where it makes sense in your context you can add
<div data-toggle-text-off="text when class is off" data-toggle-text-on="text when class is on">
The text in the data-toggle-text-off="" should be the same as the default text that you're rendering on the initial load - The text that is written to the HTML source before you start manipulating the DOM.
Watch for changes to context menu state
I've added a new menu item to the context menu, which triggers a Javascript function to toggle a class on the main menu. What I'd like to do now is change the menu item text depending on the presence/absence of that class.
Given that the context menu is dynamically built on each request, changes I make to the context menu as part of the initial function are lost when it is destroyed. Also looks like the contextmenu event is supressed as adding an event handler doesn't work.
Is there any way I can either add a listener for right-clicking the menu items, or be notified when the context menu is open?
cheers Nathan
Hi Nathan
I'm assuming that it's a menu rendering on your public facing website you're talking about?
I don't know what your code looks like but you should be able to have the text for the different toggle states saved in data-* attributes so on an element where it makes sense in your context you can add
The text in the data-toggle-text-off="" should be the same as the default text that you're rendering on the initial load - The text that is written to the HTML source before you start manipulating the DOM.
I hope this makes any sense.
/Jan
Hi Jan
Sorry, I was vague - I meant the back office menu/content tree
is working on a reply...