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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:50:50+00:00 2026-05-15T04:50:50+00:00

At the moment I have two (maybe more) unordered lists which are sortable with

  • 0

At the moment I have two (maybe more) unordered lists which are sortable with jquery and ui.

The things that work are that the lists are connected, items are draggable, items can be removed and a form that adds to the list.

What I need however is a function that gets all the content for li items and json encode them ready to be sent off to some db function, or something.

Im new to jquery however and cant find documentation for li items.

Hope Ive explained this well.

Daniel

UPDATE – Sample Code

    <script type="text/javascript">

    function addSortable(value) {
        $("#sortable1").prepend("<li class='ui-state-default' id='"+value+"'><span class='ui-icon ui-icon-arrowthick-2-n-s'></span>"+value+"</li>");
    }

    function deleteItem(value) {
        $("#item-"+value).fadeOut('slow');

        $('#sortable1 li').each(function() {
            var text = $(this).text();
        });

        document.getElementById('jsoningreds').innerHTML = text;

    }

    $(function() {
        $("#sortable1, #sortable2").sortable({
            connectWith: '.connectedSortable'
        }).disableSelection();
    });
    </script>

    <ul id="sortable1" class="connectedSortable">

    <li id="item-0" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>8 large chicken thighs, skinned <a href="javascript:deleteItem(0)" class="deleteItem"></a></li>

    <li id="item-1" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>seasoned flour (celery salt, cayenne pepper, paprika and white pepper) <a href="javascript:deleteItem(1)" class="deleteItem"></a></li>
    <li id="item-2" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>2 small eggs, beaten <a href="javascript:deleteItem(2)" class="deleteItem"></a></li>
    <li id="item-3" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>100g butter <a href="javascript:deleteItem(3)" class="deleteItem"></a></li>
    </ul>

    <hr />

    <h3>Recipe number 2</h3>
    <ul id="sortable2" class="connectedSortable">

<li id="item-5" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>3 tsp vegetable oil <a href="javascript:deleteItem(5)" class="deleteItem"></a></li>
    <li id="item-6" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>1 bay leaf <a href="javascript:deleteItem(6)" class="deleteItem"></a></li>
    <li id="item-7" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>250g onions, finely sliced <a href="javascript:deleteItem(7)" class="deleteItem"></a></li>
    </ul>

   <p id="jsoningreds">hello</p>    
  • 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-15T04:50:50+00:00Added an answer on May 15, 2026 at 4:50 am

    You might want to look at .sortable('serialize') – It may solve your problem for you:

    Serializes the sortable’s item id’s
    into a form/ajax submittable string.
    Calling this method produces a hash
    that can be appended to any url to
    easily submit a new item order back to
    the server.

    It works by default by looking at the
    id of each item in the format
    'setname_number', and it spits out a
    hash like
    "setname[]=number&setname[]=number".

    You can also give in a option hash as
    second argument to custom define how
    the function works. The possible
    options are: key (replaces part1[]
    with whatever you want), attribute
    (test another attribute than id) and
    expression (use your own regexp).

    If serialize returns an empty string,
    make sure the id attributes include an
    underscore. They must be in the form:
    "set_number" For example, a 3 element
    list with id attributes foo_1, foo_5,
    foo_2 will serialize to
    foo[]=1&foo[]=5&foo[]=2. You can use
    an underscore, equal sign or hyphen to
    separate the set and number. For
    example foo=1 or foo-1 or foo_1 all
    serialize to foo[]=1.

    If serialize does more than you need, .sortable('toArray') should return you an array containing the ids of each element in the sortable.

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

Sidebar

Related Questions

I have two questions. 1: At the moment I have two model classes that
I have an application that has two localization options at the moment through .resx
At the moment I have a jQuery do a POST to a Controller which
At the moment I have two tables, products and options . Products contains id
I have two nested loop in XSL like this, at this moment I use
So, I have two types at the moment: const unsigned char* unencrypted_data_char; string unencrypted_data;
I am making two sites at the moment and have come up to a
So at the moment I have a multidimensional array string[,] items = new string[100,
At the moment I have a slider and an small input text box which
At the moment I have a DocumentViewer in a WPF window that displays an

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.