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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:08:43+00:00 2026-05-26T09:08:43+00:00

I am using JQuery 1.5.1 and JQuery UI 1.8.11. I have added sortable for

  • 0

I am using JQuery 1.5.1 and JQuery UI 1.8.11.

I have added sortable for a number of items – the task here is to allow drag to sort, this all works fine.

But I also want to incorporate droppable, so that the item can be dropped onto a “copy me” area – the task there will be to duplicate the item (I will work that bit out later)

Problem is the droppable target is at the bottom of the sortable list (I do not want to move this) and once the drop occurs the sortable item moves to the bottom of the list.

What I want to do is cancel this sort when the drop event fires.

You can see my problem in action here (just drag “Item 1” onto the “Drop to Copy Item” area and you will see the sort does not get cancelled)

As you can see I have tried the following in the droppable “drop” event (suggested from JQuery UI Docs) but it does not seem to work…

$(this).sortable('cancel');

I am also open to any other recommendations on how to achieve this “drop to copy” effect I am looking for.

Thanks

  • 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-26T09:08:44+00:00Added an answer on May 26, 2026 at 9:08 am

    OK, so I have worked out a solution which does the job.

    the cancel code does work if you have it in the “stop” event of the sortable function. However, it will only apply once the “revert” has completed. The problem is that I was trying to copy/revert the element from the droppable “drop” event and this was too early.

    The solution is to wait for the “stop” event to complete, and to achieve this I had to create a “awaiting copy” flag, to be checked in the “stop” event.

    Here is an example

    It still doesn’t feel right (UX-wise) but it works correct, and you could always set revert to false on the sortable function to get a slightly better feel.

    The code from the example is as follows…

    var itemCount = 3;
    var awaitingCopy = false;
    
    $(init);
    
    function init() {
        $("#Items").sortable({
            revert: true,
            placeholder: "ItemPlaceHolder",
            opacity: 0.6,
            start: StartDrag,
            stop: StopDrag
        });
    
        $("#CopyItem").droppable({
            hoverClass: "CopyItemActive",
            drop: function(event, ui) {
                awaitingCopy = true;
            }
        });
    
        $("#NewItem").click(function(e) {
            e.preventDefault();
            itemCount++;
            var element = $("<div class='Item'>Item " + itemCount + "</div>");
            $("#Items").append(element);
            element.hide().slideDown(500);
        });
    }
    
    function CopyItem(element) {
        awaitingCopy = false;
        var clone = element.clone();
        $("#Items").append(clone);
        clone.hide().slideDown(500);
    }
    
    function StartDrag() {
        $("#NewItem").hide();
        $("#CopyItem").show();
    }
    
    function StopDrag(event, ui) {
        if (awaitingCopy) {
            $(this).sortable('cancel');
            CopyItem($(ui.item));
        }
        $("#NewItem").show();
        $("#CopyItem").hide();
    }
    

    Anyway, hopefully this will help others who want the same kind of effect… no stealing my design though 😉

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

Sidebar

Related Questions

I am using jquery validation plugin for form validation. I have added a custom
I have a View where some input text to be added dynamica using jquery,
I am dynamically generating an anchor tag using jQuery. I have added an onclick
I have dynamically added an element in page using jquery with following function. function
I am using jQuery UI sortable to sort a list in the DOM. I
I have a table I'm using jQuery UI's sortable on. In the table, I
I have added a group of radio buttons dynamically to the DOM using jQuery.
so I have built my own drag and drop shopping cart(very basic) using Jquery
I have added the client side validations on a form using jQuery's validate() function
I have a form in which there are textbox(s) added dynamically using jquery. The

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.