jQuery Accordion "End"

jQuery Accordion "End"

  1. I have an accordion setup with jQuery on my SharePoint site...my code is below
  2. When I collapse the last H2 header, everything below it collapses, to include my Web Parts, and other text.
  3. How do I "end" the accordion so that the remaining content on my site is not collapsed as well.


  4. <script language="javascript" type="text/javascript" src="WhatWhatWhat.com/SiteAssets/jquery-3.2.1.min.js"></script>
    <script language="javascript" type="text/javascript">
    $(document).ready(function () {
    var inEditMode = Utils.checkPageInEditMode();
    // Prevent the collapsing of <h2> blocks when in SharePoint's [Edit Mode]
    if (!inEditMode) {
    UI.collapseContentHeaders();
    UI.toggleContentHeaders();
    }
    });
    var UI = {
    collapseContentHeaders: function () {
    $('#DeltaPlaceHolderMain h2').each(function (index, value) {
    // Collapses all <h2> blocks except for the first encountered
    if (index > 0) {
    $(this).toggleClass('expand').nextUntil('h2').slideToggle(100);
    }
    });
    },
    toggleContentHeaders: function () {
    // Toggles the accordion behavior for <h2> regions onClick
    $('#DeltaPlaceHolderMain h2').click(function () {
    $(this).toggleClass('expand').nextUntil('h2').slideToggle(100);
    });
    }
    }
    var Utils = {
    checkPageInEditMode: function () {
    var pageEditMode = null;
    var wikiPageEditMode = null;
    // Edit check for Wiki Pages
    if (document.forms[MSOWebPartPageFormName]._wikiPageMode) {
    wikiPageEditMode = document.forms[MSOWebPartPageFormName]._wikiPageMode.value;
    }
    // Edit check for all other pages
    if (document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode) {
    pageEditMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value;
    }
    // Return the either/or if one of the page types is flagged as in Edit Mode
    if (!pageEditMode && !wikiPageEditMode) {
    return false;
    }
    return pageEditMode == "1" || wikiPageEditMode == "Edit";
    }
    }
    </script>