简体   繁体   English

活动页面上的手风琴菜单崩溃

[英]Accordion menu collapsing when on active page

I've built a vertical accordion nav with jQuery 1.4.3 and jQuery UI 1.8.5 in order to support the hoverintent version of the accordion widget. 我已经使用jQuery 1.4.3和jQuery UI 1.8.5构建了一个垂直手风琴导航,以支持手风琴小部件的悬浮式版本。

It works as expected, however the menu collapses when the user navigates to another page. 它可以按预期工作,但是当用户导航到另一个页面时,菜单会折叠。

Is there something that I have overlooked? 有什么我忽略的东西吗?

The HTML HTML

<nav class="span3">
<a href="index.html"><img src="img.png" width="250" /></a>
<ul class="wrap" id="mainNav">
    <li>
        <a href="javascript:void(0);" class="accordionButton">Lorem</a>
        <ul class="accordionContent" style="display: none;">
            <li>
                <a href="javascript:void(0);">Ipsum</a>
            </li>
            <li class="">
                <a href="javascript:void(0);">Dolor</a>
            </li>
            <li>
                <a href="javascript:void(0);">Sit</a>
            </li>
        </ul>
    </li>
    <li>
        <a href="javascript:void(0);" class="accordionButton accordionButton noChild">Amet</a>
    </li>
    <li>
        <a href="javascript:void(0);" class="accordionButton accordionButton noChild">Consectetur</a>
    </li>
    <li>
        <a href="javascript:void(0);" class="accordionButton accordionButton noChild">Adipiscing</a>
    </li>
    <li>
        <a href="javascript:void(0);" class="accordionButton accordionButton noChild">Elit</a>
    </li>
</ul>
</nav>

The JavaScript JavaScript

// verticle menu
function vertAccordHover() {"use strict";
    $accButtons.mouseover(function() {
        $(this).addClass('hover');
    }).mouseout(function() {
        $(this).removeClass('hover');
    });
}

function vertAccord() {"use strict";

    $("#mainNav").accordion({
        event : "mouseover",
        alwaysOpen : false,
        autoHeight : false,
        navigation : true,
        collapsible : true
    });

    $('.noChild').unbind('mouseover');
    $('#mainNav').accordion('activate', 0);                
    $('#mainNav').accordion( "option", "navigation", true );

    vertAccordHover();
}

Your accordion would collapse every time you go to a new page because your browser reloads the page from scratch. 每次进入新页面时,您的手风琴都会崩溃,因为浏览器会从头开始重新加载页面。 You don't have a way to store the state of your accordion before exiting a page. 您无法在退出页面之前存储手风琴的状态。 You could probably do this by storing a cookie on your user's browser 您可以通过在用户浏览器中存储Cookie来实现此目的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM