Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question menu expand script keeps link from being followed

    Hi,

    A have a generated piece of javascript for expanding a vertical menu without reloading.
    The expand wihout reload works fine but my problem is if the first level link is clicked it does not follow the url and only expands the lower levels.
    The html structure is : ul>li(a)>ul>li(a).
    The first link is not followed.

    What should be changed in the code to let it open the submenu and following the url.

    the piece of scipt is this:
    jQuery(function() {
    'use strict';
    setOpenSubmenuWithNoReload({vMenuClass: "art-vmenu", activeClass: "active", hoveredClass: "hovered"});
    });

    var setOpenSubmenuWithNoReload = (function($) {
    'use strict';
    return (function(vMenuInfo) {
    $("ul." + vMenuInfo.vMenuClass + " li").each(function () {
    var item = $(this);
    item.children("a").bind("click", function(e) {
    var link = $(this);
    var simple = link.siblings("ul").length === 0;
    link.parent().siblings().children("ul." + vMenuInfo.activeClass).slideUp(function() {
    $(this).find("li, a, ul").removeClass(vMenuInfo.activeClass);
    $(this).removeClass(vMenuInfo.activeClass).siblings("a").removeClass(vMenuInfo.activeClass);
    $(this).css("display", "");
    });
    link.parent().siblings().children("a." + vMenuInfo.activeClass).removeClass(vMenuInfo.activeClass);
    link.parent().siblings().removeClass(vMenuInfo.activeClass);
    if (simple && !link.hasClass(vMenuInfo.activeClass)) {
    link.addClass(vMenuInfo.activeClass).parent().addClass(vMenuInfo.activeClass);
    }
    if (!simple) {
    if (link.hasClass(vMenuInfo.activeClass)) {
    link.siblings("ul").slideUp("fast", function() {
    $(this).removeClass(vMenuInfo.activeClass).siblings("a").removeClass(vMenuInfo.activeClass).parent() .removeClass(vMenuInfo.activeClass);
    $(this).css("display", "");
    });
    } else {
    link.siblings("ul").slideDown("fast", function() {
    $(this).addClass(vMenuInfo.activeClass).siblings("a").addClass(vMenuInfo.activeClass).parent().addCl ***(vMenuInfo.activeClass);
    $(this).css("display", "");
    });
    }

    e.preventDefault();
    return false;
    }
    });
    });
    });
    })(jQuery);

    any help would be very much appreciated.

    kind regards, Peter

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    try this

    Code:
    jQuery(function() {
    'use strict';
    setOpenSubmenuWithNoReload({vMenuClass: "art-vmenu", activeClass: "active", hoveredClass: "hovered"});
    });
    
    var setOpenSubmenuWithNoReload = (function($) {
    'use strict';
    return (function(vMenuInfo) {
    $("ul." + vMenuInfo.vMenuClass + " li").each(function () {
    var item = $(this);
    item.find("a").bind("click", function(e) {
    var link = $(this);
    var simple = link.siblings("ul").length === 0;
    link.parent().siblings().children("ul." + vMenuInfo.activeClass).slideUp(function() {
    $(this).find("li, a, ul").removeClass(vMenuInfo.activeClass);
    $(this).removeClass(vMenuInfo.activeClass).siblings("a").removeClass(vMenuInfo.activeClass);
    $(this).css("display", "");
    });
    link.parent().siblings().children("a." + vMenuInfo.activeClass).removeClass(vMenuInfo.activeClass);
    link.parent().siblings().removeClass(vMenuInfo.activeClass);
    if (simple && !link.hasClass(vMenuInfo.activeClass)) {
    link.addClass(vMenuInfo.activeClass).parent().addClass(vMenuInfo.activeClass);
    }
    if (!simple) {
    if (link.hasClass(vMenuInfo.activeClass)) {
    link.siblings("ul").slideUp("fast", function() {
    $(this).removeClass(vMenuInfo.activeClass).siblings("a").removeClass(vMenuInfo.activeClass).parent() .removeClass(vMenuInfo.activeClass);
    $(this).css("display", "");
    });
    } else {
    link.siblings("ul").slideDown("fast", function() {
    $(this).addClass(vMenuInfo.activeClass).siblings("a").addClass(vMenuInfo.activeClass).parent().addCl ***(vMenuInfo.activeClass);
    $(this).css("display", "");
    });
    }
    
    e.preventDefault();
    return false;
    }
    });
    });
    });
    })(jQuery);

  • #3
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi DanInMa,

    first off all thanks for your support!

    I have tried this change but unfortunately the link is still not followed.
    Might there be another option worth to try?

    Regards, Peter


  •  

    Tags for this Thread

    Posting Permissions

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