Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Fine Tuning Multiple Mega Menus

  1. #11
    Join Date
    Jan 2013
    Location
    Edmonton, AB
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If there was an emoticon for Choirs of Angels echoing from the heavens you would be CLOSE to the feeling I'm experiencing right now.

    THANK YOU hardly comes close. Let's hope I don't break it all now in trying to stylize the individual DIVs. I promise to work cautiously.

    Thanks again John. I will sleep peacefully tonight. http://www.adventureswithkd.com/dd_MenuTest4.html

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You're welcome. As promised I looked to see if it could be made more generic and/or incorporated into the script. That doesn't seem very feasible though. What I've come up with is a configurable version in case you need to change the key variables. As is it does exactly the same thing it did before. It simply makes it clear what items are variable that you might change if the markup changes. These are at the beginning and commented. Let me know if you have any questions about what they are:

    Code:
    jQuery(function($){
    	var $alignwith = $('.content'); //jQuery object to align drop menus to
    	var offset = 5; // offset from that object
    	var $triggers = $('.solidblockmenu a'); // jQuery object of top level menu triggers
    	function relocate(){
    		$(this).unbind('mouseenter.relocate');
    		var smo = $alignwith.offset().left;
    		$('.megawrapper').each(function(){
    			var $t = $(this);
    			$t.children('div:first').css({left: smo - $t.offset().left + offset});
    		});
    	}
    	$triggers.bind('mouseenter.relocate', relocate);
    	$(window).resize(function(){
    		$triggers.unbind('mouseenter.relocate').bind('mouseenter.relocate', relocate);
    	});
    });
    And here's a slightly enhanced version that prevents a horizontal scrollbar when resizing the window down after having displayed one or more drop downs:

    Code:
    jQuery(function($){
    	var $alignwith = $('.content'); //jQuery object to align drop menus to
    	var offset = 5; // offset from that object
    	var $triggers = $('.solidblockmenu a'); // jQuery object of top level menu triggers
    	function relocate(){
    		$(this).unbind('mouseenter.relocate').data('adjusted', true);
    		var smo = $alignwith.offset().left;
    		$('.megawrapper').each(function(){
    			var $t = $(this);
    			$t.children('div:first').css({left: smo - $t.offset().left + offset});
    		});
    	}
    	$triggers.bind('mouseenter.relocate', relocate);
    	$(window).resize(function(){
    		$triggers.each(function(){
    			if($(this).data('adjusted')){
    				relocate.call(this);
    				return false;
    			}
    		});
    		$triggers.unbind('mouseenter.relocate').bind('mouseenter.relocate', relocate);
    	});
    });
    Last edited by jscheuer1; 01-31-2013 at 04:28 PM. Reason: add enhanced version
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. DD Mega Menu multiple levels
    By taaamara in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-22-2012, 02:50 AM
  2. Need help with multiple menus
    By Jim Weinberg in forum Looking for such a script or service
    Replies: 0
    Last Post: 02-10-2012, 08:20 PM
  3. Multiple Tabbed menus
    By searchable2 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-13-2007, 02:03 PM
  4. Multiple DD Tab Menus in the same page
    By drunkdriver in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 05-05-2006, 12:01 PM
  5. Multiple Tab Menus on Same Page
    By JMax in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 11-10-2004, 06:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •