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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:04:16+00:00 2026-06-05T23:04:16+00:00

Problem ( jsFiddle demo of the problem ) I’m having some trouble with the

  • 0

Problem (jsFiddle demo of the problem)

I’m having some trouble with the revert setting when used in conjunction with the cancel method in the jQuery sortable. The cancel method, as documented in the jQuery Sortable documentation states:

Cancels a change in the current sortable and reverts it back to how it
was before the current sort started. Useful in the stop and receive
callback functions.

This works fine in both the stop and receive callbacks, however if I add a revert duration to the sortable connected list, it starts to act funny (see jsFiddle here).

Ideally, upon cancelling, the revert could simply not happen, or alternatively in a more ideal world, it would gracefully revert to it’s original location. Any ideas how I can get the revert and cancel to play nice?

Expected

  1. Drag from left list to right list
  2. Drop item
  3. Item animates to original location – or – immediately shifts to original location

Actual

  1. Drag from left list to right list
  2. Drop item
  3. Item animates to new location, assuming sortable is successful
  4. Item immediately shifts to original location, as sortable was cancelled

Clarification

The revert property moves the item to the location where the item would drop if successful, and then immediately shifts back to the original location due to the revert occurring before the cancel method. Is there a way to alter the life-cycle so if the cancel method is executed, revert isn’t, and instead the item is immediately return to it’s original location?

  • 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-05T23:04:18+00:00Added an answer on June 5, 2026 at 11:04 pm

    After many hours for searching for a solution I decided the only way to achieve what I was trying to do was to amend the way in which the jQuery sortable plugin registered the revert time. The aim was to allow for the revert property to not only accept a boolean or integer, but also accept a function. This was achieved by hooking into the prototype on the ui.sortable with quite a lot of ease, and looks something like this.

    jQuery Sortable Hotfix

    $.ui.sortable.prototype._mouseStop = function(event, noPropagation)
    {
        if (!event) return;
    
        // if we are using droppables, inform the manager about the drop
        if ($.ui.ddmanager && !this.options.dropBehaviour)
            $.ui.ddmanager.drop(this, event);
    
        if (this.options.revert)
        {
            var self = this;
            var cur = self.placeholder.offset();
    
            // the dur[ation] will not determine how long the revert animation is
            var dur = $.isFunction(this.options.revert) ? this.options.revert.apply(this.element[0], [event, self._uiHash(this)]) : this.options.revert;
    
            self.reverting = true;
    
            $(this.helper).animate({
                left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
                top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
            }, !isNaN(dur) ? dur : 500, function ()
            {
                self._clear(event);
            });
        } else
        {
            this._clear(event, noPropagation);
        }
    
        return false;
    }
    

    Implementation

    $('ul').sortable({
        revert: function(ev, ui)
        {
            // do something here?
            return 10;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's some code to illustrate the problem I'm running into. jsFiddle Demo <div class=normal>
Problem: I am having trouble implementing a recursive image lazy load in all relevant
Original demo http://jsfiddle.net/anglimass/NVTzx/9/ Updated demo (that actually demonstrates the problem) http://jsfiddle.net/NVTzx/16/ Please click see
I created a simple demo here that demonstrates the problem: http://jsfiddle.net/boblauer/eCugY/ Basically, I want
I've setup a demo of my problem at the following url: http://jsfiddle.net/YHHg7/4/ I'm trying
Im having a big headcache with a header design: Here the demo: http://jsfiddle.net/uGECm/ The
i'm having a little problem with jquery/javascript countdown and i'm hoping you can help
Here's an example of my problem on jsFiddle. I have a table with striped
I've created an example of the problem here: http://jsfiddle.net/JustinN/qWeLT/1/ My actual code is hooked
jsFiddle of the problem here. When I have an image with align=left inside a

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.