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.

Dynamic submenu width

Home Forums Older releases 0.9.x Dynamic submenu width

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1343
    Prasanth
    Participant

    Can I make the width of sub menus to its parent main menu?

    #1716
    admin
    Keymaster

    It’s not completely clear how exactly you would like it to function from your question so I’ve done what I suspect you need. The following mod will make sure your first level sub menus get the width of their respective parent menu item:

    $('#main-menu').bind('beforeshow.smapi', function(e, menu) {
    	var $menu = $(menu),
    		obj = $(this).data('smartmenus');
    	// save default subMenusMinWidth and subMenusMaxWidth options
    	if (typeof obj.opts._subMenusMinWidth == 'undefined') {
    		obj.opts._subMenusMinWidth = obj.opts.subMenusMinWidth;
    		obj.opts._subMenusMaxWidth = obj.opts.subMenusMaxWidth;
    	}
    	// if this is a first level sub menu
    	if ($menu.dataSM('level') == 2) {
    		$menu.css('width', obj.getWidth($menu.dataSM('parent-a')));
    		// unset subMenusMinWidth and subMenusMaxWidth options so that the script doesn't override our custom width for this sub
    		obj.opts.subMenusMinWidth = '';
    		obj.opts.subMenusMaxWidth = '';
    	} else {
    		// restore subMenusMinWidth and subMenusMaxWidth options for deeper sub menu levels
    		obj.opts.subMenusMinWidth = obj.opts._subMenusMinWidth;
    		obj.opts.subMenusMaxWidth = obj.opts._subMenusMaxWidth;
    	}
    });

    For 2+ level sub menus, the subMenusMinWidth and subMenusMaxWidth options will be respected like normally.

    #1717
    Prasanth
    Participant

    First of all thank you for your support.

    This is the site I am tried to add menu.
    http://tasaheelgroup.org/petrolead/

    There you can see in the third and fourth menu, the submenus width is less than its parent menu. I want it exactly the same width that of the main menu.

    I added the script you given to the file jquery.smartmenus.js, but its not working.

    Please help me…

    #1720
    Prasanth
    Participant

    Sorry to disturb you its worked..
    Thanks..Thanks a lot..

    #2753
    jimbob
    Participant

    Hi admin,

    thank you very much for sharing the code.
    It help me alot.

    Greetings
    Jimbob

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