How to disable/enable only one sub menu?

Home Forums Older releases 0.9.x How to disable/enable only one sub menu?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1377
    juliandormon
    Participant

    Hi There,
    I have applied SM to a group of links such that there are multiple links that spawn sub menus. I was hoping there was a method to disable/enable just one of these sub menus – not the whole parent.

    #1693
    admin
    Keymaster

    Hi,

    Sorry but I don’t understand what exactly you mean. Please post some code sample if possible (a live demo would be best) and try to explain what exactly you would try to achieve and I will try to help you out.

    Thanks!

    #1695
    juliandormon
    Participant
    <ul>
    <li>link1</li>
    <li>link2</li>
    <li><a class="has=submenu">Menu 1 </a></li>
    <li>link3</li>
    <li>link4</li>
    <li><a class="has=submenu">Menu 2 </a></li>
    </ul>

    How can I disable Menu 2 only? Thanks!!!

    #1696
    admin
    Keymaster

    OK, there is no available method for this, but you could achieve it, for example, with some custom functions like these:

    function disableItem($parentLI) {
    	$parentLI.on('mouseenter.smartmenus mouseleave.smartmenus mousedown.smartmenus focus.smartmenus blur.smartmenus click.smartmenus touchend.smartmenus', 'a', function(e) {
    		e.stopPropagation();
    		e.preventDefault();
    	});
    }
    
    function enableItem($parentLI) {
    	$parentLI.off('mouseenter.smartmenus mouseleave.smartmenus mousedown.smartmenus focus.smartmenus blur.smartmenus click.smartmenus touchend.smartmenus');
    }

    When calling any of these you will need to pass the item’s LI element as an argument. For example, if you have the following HTML:

    ...
    <li id="myParentItem"><a>Menu 2 </a>
    	<ul>...</ul>
    </li>
    ...

    you could use the following JS to disable/enable the item (and its sub menu):

    disableItem($('#myParentItem'));
    enableItem($('#myParentItem'));
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?