jQuery UI Accordion Menu - 如果用户点击该面板中的链接,则保持面板打开

时间:2014-05-23 19:21:57

标签: jquery-ui jquery-ui-accordion

我正在创建一个jQuery手风琴菜单。当单击其中一个子链接时,我需要打开正确的面板。

因此,如果在“咨询”下单击“简介”,用户将转到“简介”页面,“咨询”面板将打开。或者,如果在“RPO”下单击“值”,则当用户进入该页面时,“RPO”面板将保持打开状态等。有没有办法执行此操作?

  <ul id="nav-side" class="accordion">
    <li class="accordion-title"><a href="#">RPO</a>
        <ul>
        <li><a href="/rpo/index.php">Value</a></li>
        <li><a href="/rpo/solution-competencies.php">Solution Competencies</a></li>
        <li><a href="/rpo/rpo-models.php">Defined RPO Models</a></li>
        <li><a href="/rpo/program-management.php">Dedicated Program Management</a></li>
        <li><a href="/rpo/solution-planning.php">Solution Planning &amp; Implementation</a></li>
      </ul>
    </li>
    <li class="accordion-title"><a href="#">CONSULTING</a>
        <ul>
        <li><a href="/consulting/index.php">Intro</a></li>
        <li><a href="#">#</a></li>
        <li><a href="#">#</a></li>
      </ul>
    </li>
    <li class="accordion-title"><a href="#">CRM</a>
        <ul>
        <li><a href="#">#</a></li>
        <li><a href="#">#</a></li>
        <li><a href="#">#</a></li>
      </ul>
    </li>
  </ul>

JS:

    $(function() {
    var icons = {
      header: "ui-icon-plusthick",
      activeHeader: "ui-icon-minusthick"
    };
    $( ".accordion" ).accordion({
      icons: icons,
            heightStyle: "content"
    });
    $( "#toggle" ).button().click(function() {
      if ( $( ".accordion" ).accordion( "option", "icons" ) ) {
        $( ".accordion" ).accordion( "option", "icons", null );
      } else {
        $( ".accordion" ).accordion( "option", "icons", icons );
      }
    });
  });

0 个答案:

没有答案