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 9255947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:49:32+00:00 2026-06-18T11:49:32+00:00

Is it possible to make a jquery accordion sortable only when all elements are

  • 0

Is it possible to make a jquery accordion sortable only when all elements are collapsed? I have a sortable accordion, but when the active element is moved , it breaks the css on the page (rearranges the columns,). I know this is likely a problem with the css on the site rather than the accordion, but I don’t have permissions to adjust all of the css. Below is the code I am using to create the accordion:

<script type='text/javascript'>

    var selected = new  Array();
    var ids = new Array();
    var counter = <?php echo (req('fd_id'))? count($results): 0;?>;
    $(document).ready(function(){
        $("#livesearch").bind("keyup", function () {
                var value = escape($("#livesearch").val());
                if (value.length == 0)
                    $("#results").fadeOut(500);
                else
                {
                    $("#results").fadeIn(500);
                    $("#results").load("<?php echo matry::base_to('utilities/search/referral_search&str=')?>" + value);
                }
            });
        $(function () {
            $("#trip_list").accordion({
                header: ">li >h3",
                collapsible: true
            }).sortable({
                axis: 'y',
                handle: 'h3',
                stop: function(event, ui)
                {
                    ui.item.children( "h3" ).triggerHandler( "focusout" );
                }
            });

            });
        $("#livesearch").blur(function(){$("#livesearch").val(""); $("#results").fadeOut(500);});
        $("#reset").click(function(){$("#trip_list").html("");});
        $("button.remove").on('click', function (){
                $(this).parents('li').remove();
            });
        $("button#save").on('click', function (){
                $.ajax({
                    type: 'POST',
                    url: '<?php echo matry::base_to('utilities/crm/field_day_save');?>',
                    data: $("form#trip_form").serialize(),
                    dataType: 'json',
                    success: function (data)
                    {
                        $("#alerts").html(data.alert);
                        $("#form_id").val(data.id);
                    }
                    });
            });
    });

    function selectItem(id)
    {
        if (counter < 20) //only allow 20 referral sources at a time
        {
            $.get("<?php echo matry::base_to('utilities/field_day'); ?>&rfcode=" + id + "&count=" + counter, function(data){
                        $("#trip_list").append(data).accordion('destroy').accordion({header: "li >h3", collapsible: true});}); 
            counter++;
        }
    }

</script>

Update

I have added the following, but it only works on the Second or more panels. The first panel ignores it. Any suggestions?

$(function () {
            $("#trip_list").accordion({
                header: "li >h3",
                active: false,
                collapsible: true,
                activate: function(){if($(this).accordion('option', 'active')){$(this).sortable('disable');}else $(this).sortable('enable');}
            }).sortable({
                axis: 'y',
                handle: 'h3',
                stop: function(event, ui)
                {
                    ui.item.children( "h3" ).triggerHandler( "focusout" );
                }
            });
  • 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-06-18T11:49:33+00:00Added an answer on June 18, 2026 at 11:49 am

    1. Use sortable() methods in accordion() event

    Using the accordion’s accordionactivate event which fires whenever an accordion panel is opened or closed, you can check if the accordion is collapsed or not, and apply the .sortable('enable') or .sortable('disable') methods in accordance.

    2. Detect if the accordion is collapsed

    To detect the state of the accordion in the event handler, you can check the ui.newPanel property, which is a jQuery object containing the newly opened accordion panel. If ui.newPanel is not an empty object, then it means the accordion is not collapsed (i.e a closed panel was clicked). Similarly, if ui.newPanel is an empty object, then it means the accordion is completely collapsed (i.e an open panel was clicked and no new panel opened in its place).

    Example and demo

    $('#accordion').accordion({...}).sortable({...});
    
    $('#accordion').on('accordionactivate', function (event, ui) {
         // Accordion is not collapsed
        if (ui.newPanel.length) {
            $('#accordion').sortable('disable');
         // Accordion is collapsed
        } else {
            $('#accordion').sortable('enable');
        }
    });
    

    See jsFiddle demo

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

Sidebar

Related Questions

Is it possible to make an element to be always on top with jQuery?
im using jquery to make ajax requests. is it possible to detect if the
I want make datetimepicker in my project. Using jquery how it is possible? I
How is it possible to make knockout data-bind work on dynamically generated elements? For
According to the developer documentation jquery plugins are supposed to have only one namespace
Does anyone know if it's possible to make the DynaTree jquery plugin handle two
I try to make jquery live color switcher but i need to know is
Possible Duplicate: How can I upload files asynchronously with JQuery? I have a file
I want to make jQuery UI TAB blink (like notification). I have diffrent tabs
Is it possible to make. jquery ajax success, then continue load page's html? For

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.