Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

href not working on parent as expected

Home Forums Older releases 1.0.x href not working on parent as expected

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #3019
    ratmalwer
    Participant

    Hello I have the following structure:

    
    <pre><ul id="main-menu" class="sm sm-blue">
      <li><a href="#">Item 1</a></li>
      <li><a href="#">Item 2</a>
        <ul>
          <li><a href="#">Item 2-1</a></li>
          <li><a href="#">Item 2-2</a></li>
          <li><a href="#">Item 2-3</a></li>
        </ul>
      </li>
      <li><a href="#">Item 3</a></li>
    </ul></pre>
    

    Now when I click Item 2 the tree is expanding as expected. But the href of item 2 does not fire. By clicking item 2 a second time href is firing. How can i let it fire the first time I click it (while it expands)?

    #3025
    admin
    Keymaster

    Here is some sample code that will make the main menu links load on first click/tap in mobile view:

    $(function() {
    	var $mainMenu = $('#main-menu');
    
    	// don't show the sub menus in collapsible mode unless the sub arrow is clicked
    	$mainMenu.on('click', 'span.sub-arrow', function(e) {
    			var obj = $mainMenu.data('smartmenus');
    			if (obj.isCollapsible()) {
    				var $item = $(this).parent(),
    					$sub = $item.closest('li').dataSM('sub');
    				$sub.dataSM('arrowClicked', true);
    			}
    		}).bind({
    			'beforeshow.smapi': function(e, menu) {
    				var obj = $mainMenu.data('smartmenus');
    				if (obj.isCollapsible()) {
    					var $menu = $(menu);
    					if (!$menu.dataSM('arrowClicked')) {
    						return false;
    					}
    					$menu.removeDataSM('arrowClicked');
    				}
    			}
    		});
    });

    Please let me know if you have any troubles.

    Cheers!

    #3032
    ratmalwer
    Participant

    Hey
    works great!!!

    Still I have a bit thinking to do.
    As I work on a CMS that the user allows to choose the menuposition (left, horizontal maybe multiple menus) I have to check it out deeper.
    In the left-menu in desktop-mode I want the menu stay expanded and active.
    On mobile view the menu should disapear after the selection.
    etc.

    Your code will help me and point the direction.
    Thanks

    #3060
    ratmalwer
    Participant

    Hello

    I come back with this issue. As mentioned it works but still does not cover my reqirements.

    I tried to change the script you provided but failed.

    The menu should react as this examlple (click the CMS_ML -item of the link : http://mk-design.ch).
    – on click the menu should expand and the href should fire and the menu should remain expaded.
    – on cklick of the sub-menu the href should fire and the menu should remain expanded.

    Is there an easy way to do this?

    #3061
    ratmalwer
    Participant

    PS:
    i think there might be the need of a new style (sm-vertical-no-flyout) as mobile-view should act as it is?!

    #8986
    goesredy
    Participant

    that script not working for multiple instance

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘1.0.x’ is closed to new topics and replies.