Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:39:55+00:00 2026-05-25T00:39:55+00:00

I have currently been working on a web application which features a dynamically updating

  • 0

I have currently been working on a web application which features a dynamically updating accordion inside a jScrollPane.

I am now trying to implement jQuery Sortable without luck.

Currently examples I have found require you to change the header tags of the accordion to “> div > h3” …where then sortable’s handler is the h3 tag.

When keeping the original headers of the accordion and trying to make sortable work, I can not seem to find any solution.

This far in the project, I can’t change the header of the accordion because a lot of the functionality will be broken and will require extensive tweaking.

Does anyone have any ideas on making this work?

Thanks,

David

EDIT: Here is the example code I tried to make work. I removed the header option in the accordion and played around with the sortable handler and the click action.

    var stop = false;
    $("#accordion h3").click(function(event) {
        if (stop) {
            event.stopImmediatePropagation();
            event.preventDefault();
            stop = false;
        }
    });

    $("#accordion").accordion().sortable({
        axis: "y",
        handle: "h3",
        stop: function() {
            stop = true;
        }
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:39:55+00:00Added an answer on May 25, 2026 at 12:39 am

    There are two major differences between your code (including what you have in the jsfiddle.net link) and the standard example on jQuery’s site. First (and probably what’s tripping you up), each accordion “member” is wrapped in its own div. That is, where you have a div designated as the accordion container, then h3, div, h3, div…, you need the accordion container and a container for each member (so accordion div > member divs > h3/content div).

    The header option in the example is spelling out the structure I described. However, if you change the structure and leave out the container (which I believe sortable needs to define what should be drag/dropped), your accordion probably still works but now is not sortable.

    Here’s a normal working example. The HTML:

    <div id="accordion">
        <div>
            <h3><a href="#">Section 1</a></h3>
            <div>
                <p>
                    Text.
                </p>
            </div>
        </div>
        <div>
            <h3><a href="#">Section 2</a></h3>
            <div>
                <p>
                    Text.
                </p>
            </div>
        </div>
        <div>
            <h3><a href="#">Section 3</a></h3>
            <div>
                <p>
                    Text.
                </p>
                <ul>
                    <li>One</li>
                    <li>Two</li>
                    <li>Three</li>
                </ul>
            </div>
        </div>
        <div>
            <h3><a href="#">Section 4</a></h3>
            <div>
                <p>
                    Text.
                </p>
                <p>
                    Text.
                </p>
            </div>
        </div>
    </div>
    

    The JS:

    var stop = false;
    $("#accordion h3").click(function(event) {
        if (stop) {
            event.stopImmediatePropagation();
            event.preventDefault();
            stop = false;
        }
    });
    $("#accordion").accordion({
        header: "> div > h3"
        })
        .sortable({
        axis: "y",
        handle: "h3",
        stop: function() {
            stop = true;
        }
    });
    

    If you change the structure now (leaving in the “accordion member containers” for sortable), it should work fine. In this example, I removed the h3 tags and made the anchors inside the accordion trigger element. I also gave the trigger elements a distinct “handle” class to distinguish them from any anchors within the members (there’s undoubtedly a better way to use jQuery selectors to do this but I’m rusty and lazy):

    <div id="accordion">
        <div>
            <a href="#" class="handle">Section 1</a>
            <div>
                <p>
                    Text...
                </p>
            </div>
        </div>
        ...
    </div>
    

    Then I changed the JS to reflect this. The accordion settings designate the path (past the needed div container) to the anchor tag. The sortable settings use our special “a.handle” so only “handle” class anchor tags will act as the sortable’s handle:

    var stop = false;
    $("#accordion h3").click(function(event) {
        if (stop) {
            event.stopImmediatePropagation();
            event.preventDefault();
            stop = false;
        }
    });
    $("#accordion").accordion({
        header: "> div > a"
        })
        .sortable({
        axis: "y",
        handle: "a.handle",
        stop: function() {
            stop = true;
        }
    });
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to implement unit testing and currently have some code that does
I have been trying to get more in to TDD. Currently keeping it simple
I need your opinion. I'm currently working on a web application, based on struts
I've been trying to make a JavaScript function for a Google Chrome web-application that
I'm currently monitoring a large network with Hobbit and have been tasked with lowering
I currently use Notepad++ for most of my development. I have been checking out
I currently have an MS Access application that connects to a PostgreSQL database via
I have not been working with Monotouch (or the iphone for that matter) for
I have been using PRETTY_FUNCTION to output the current function name, however I have
I have been asked to provide information on available techniques for assessing our current,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.