Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
Slate Docs function to keep navigation accordion open when clicking on other links in sidebar

For UX, there may be times where multiple sections need to be open at once in the sidebar. Currently, when another section header is clicked in the sidebar, other sections collapse. How do i make it so the all the sections are open and close only when i click on the section header itself

enter image description here

enter image description here

This is the code that handles this:

var $best = $toc.find("[href='" + best + "']").first();

  if (!$best.hasClass("active")) {
    // .active is applied to the ToC link we're currently on, and its parent <ul>s selected by tocListSelector
    // .active-expanded is applied to the ToC links that are parents of this one
    $toc.find(".active").removeClass("active");
    $toc.find(".active-parent").removeClass("active-parent");
    $best.addClass("active");
    $best
      .parents(tocListSelector)
      .addClass("active")
      .siblings(tocLinkSelector)
      .addClass("active-parent");
    $best.siblings(tocListSelector).addClass("active");
    $toc.find(tocListSelector).filter(":not(.active)").slideUp(150);
    $toc.find(tocListSelector).filter(".active").slideDown(150);
    if (window.history.replaceState) {
      window.history.replaceState(null, "", best);
    }
    var thisTitle = $best.data("title");
    if (thisTitle !== undefined && thisTitle.length > 0) {
      document.title =
        thisTitle.replace(htmlPattern, "") + " – " + originalTitle;
    } else {
      document.title = originalTitle;
    }
  }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The 2 following lines are where the previously selected section is closed.

    $toc.find(".active").removeClass("active");
    $toc.find(".active-parent").removeClass("active-parent");

Comment them out and every section will remind open.

EDIT: to be able to close the section when you click on it you need to replace .addClass method by toggleClass documentation. This way the active class is added if not present and remove in the opposite case.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda