Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Apr 28, 2015 @ 08:46
    Nathan Woulfe
    0

    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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 28, 2015 @ 08:52
    Jan Skovgaard
    0

    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

    <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.

    I hope this makes any sense.

    /Jan

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Apr 28, 2015 @ 08:54
    Nathan Woulfe
    0

    Hi Jan

    Sorry, I was vague - I meant the back office menu/content tree

Please Sign in or register to post replies

Write your reply to:

Draft