Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

301
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda