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

  • Home
  • SEARCH
  • 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 3455848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:39:52+00:00 2026-05-18T09:39:52+00:00

I have this markup dinamically generated through PHP/MySQL <div id=sortable> <h3>Italy</h3> <ul> <li id=row_1>Record

  • 0

I have this markup dinamically generated through PHP/MySQL

<div id="sortable">
    <h3>Italy</h3>
    <ul>
        <li id="row_1">Record > 1</li>
        <li id="row_2">Record > 2</li>
        <li id="row_3">Record > 3</li>
    </ul>

    <h3>Europe</h3>
    <ul>
        <li id="row_4">Record > 4</li>
        <li id="row_5">Record > 5</li>
        <li id="row_6">Record > 6</li>
    </ul>

    <h3>World</h3>
    <ul>
        <li id="row_7">Record > 7</li>
        <li id="row_9">Record > 9</li>
        <li id="row_8">Record > 8</li>
    </ul>
</div>
<div id="response"></div>

I can drag the LIs with jQuery UI sortable to new positions, and get their new order with “serialize”, ready for database update
As you can see, there are 3 ULs, but their N LIs are all related so I get a N-items “serialization” with each drag, and that’s exactly what I want

So, ie, if I move Record 3 in Record 1 place, I get this:

3,2,1,4,5,6,7,8,9 < this is just what I want

and not this:

3,2,1 < this is NOT what I want

This is my jQuery code:

$("#sortable").sortable({
    items: 'li',
    opacity: 0.6,
    cursor: 'move',
    update: function() {
    var order = $(this).sortable("serialize") + '&nAction=move';
    $.post("mypage.php", order, function(response){
        $("#response").html(response);
    });
}
}).disableSelection();

It’s working, but not as I’d like: I mean that I need to drag/drop only LIs within their respective UL, and NOT from one UL to another (always retaining the N-items serialization)

In other words, I’d like to be able to sort records 1, 2 and 3 among them, 4, 5 and 6 among them and 7,8,9 among them, without mixing (i.e., record 1 can’t go in group 4,5,6 nor in group 7,8,9)

Of course, always getting the N-items serialization! (and that’s the main reason why I applied “sortable” to a container dive and then specified LI items)

I tried with “containment: ‘parent'”, but it works only for the first drag/drop

Here are two online examples made with jsFiddle:

  1. The original one, with LIs going from one UL to the other
  2. The version with “containment”, that works only on the first drag but it’s a mess in the following drags
  • 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-18T09:39:52+00:00Added an answer on May 18, 2026 at 9:39 am

    http://jsfiddle.net/zAUT3/2/ – apply sortable to each individual ul separately. Then, whenever you need to serialize, just use each() to loop over all the sortables, and build up a composite serialization.


    Here’s the modified code from the jsFiddle linked above:

    $(".sortable").sortable({
        items: 'li',
        opacity: 0.6,
        cursor: 'move',
        update: function() {
            var order ='';
            $('#allGroups .sortable').each(function(i,el) {
                order += $(el).sortable("serialize") +'&';
            });
            order += 'nAction=move';
    
            alert(order);
            $.post("/echo/html/", order, function(response) {
                $("#response").html(response);
            });
        }
    }).disableSelection();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this markup: <div id=slider1> <div class=ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all> <a style=left:
I have this markup in an MVC app. <div id=ingredientlistdiv> <% Recipe recipe =
Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
I have my markup like this (for argument's sake) <div id=content></div> <div id=layout></div> <div
I have this markup. <form action='xxx.php' method='post'> <table> <tr> <th>Branch Id</th> <td><input id=branchId type=text
I have this markup: <ul><li id=link-notifications> <ul class=list-notifications style=display:none> <li><a href=/link/to>Item 1</a></li> </ul> </li>
I have this href defined in my markup: foreach (Car car in Model.Cars) {
let's say I have this set of HTML-markup and CSS #CSS .inputhelp_text { background:
I have html markup like this <button id=button1 onclick=alert='yup'></button> and I want to make
On an Aspx page, I have this markup (setup for a jQuery UI dialog):

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.