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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:15:00+00:00 2026-05-20T01:15:00+00:00

I am using the jQuery UI Draggable/Sortable demo (http://jqueryui.com/demos/draggable/#sortable) for the basis of my

  • 0

I am using the jQuery UI Draggable/Sortable demo (http://jqueryui.com/demos/draggable/#sortable) for the basis of my project. I need to get a reference to the <li> that gets cloned into the sortable when the sortable receives it. I tried the sortable’s receive event, but that only gives a reference to the original draggable <li>, and not its clone.

  • 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-20T01:15:01+00:00Added an answer on May 20, 2026 at 1:15 am

    In the demo you reference, there’s actually a bug; after you drag an item down it inserts a cloned li with an id which is a duplicate of its brother’s into the DOM, so beware (a bug was filed about this but there’s no activity around it).

    I did a few things to achieve this:

    1. To get around the limitation of the demo that I described above, instead apply a class to the draggable items that will be linked to the sortable:

      <ul>
          <li class="new-item ui-state-highlight">Drag me down</li>
      </ul>
      
    2. Make items with that class draggable, instead of selecting an element by id:

       $(".new-item").draggable({
           connectToSortable: "#sortable",
           helper: "clone",
           revert: "invalid"
       });
      
    3. Tap into the stop event of the sortable, and perform some simple logic about the item that was dropped, leveraging the fact that an item with the class new-item could only have been dropped (and isn’t simply an existing item in the sortable):

      $("#sortable").sortable({
          revert: true,
          stop: function(event, ui) {
              if (ui.item.hasClass("new-item")) {
                  // This is a new item
                  ui.item.removeClass("new-item");
                  ui.item.html("<b>HI</b>");
              }
          }
      });
      

    Note that you could use the data-* attribute instead of adding a helper class.

    Here’s a working example: http://jsfiddle.net/andrewwhitaker/twFCu/

    Hope that helps.

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

Sidebar

Related Questions

I am using jQuery UI; Draggable http://jqueryui.com/demos/draggable invoked like this: $(document).ready(function(){ $(#side_bar).sortable({ revert: true
Using jQuery, is there a way to select all tag that reference a specific
I'm using JQuery's Sortable (not Draggable or Droppable) and I was wondering how I
I have object (div-box), and it's draggable (I'm using jQuery). How I can get
I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of
Hoping that using something like this demo it is possible to drag items within
A small question hopefully with a simple answer, I am using jQuery draggable and
I am using jquery ui for drag and drop. I am trying to get
Onclick on image I need to change the background of li using jquery LI
I recently ran into some troubles using JQuery Draggable and Resizable plugins. Looking 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.