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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:09:55+00:00 2026-05-22T16:09:55+00:00

On ui draggables ( http://jqueryui.com/demos/droppable/#revert ) is it possible to revert a div if

  • 0

On ui draggables ( http://jqueryui.com/demos/droppable/#revert ) is it possible to revert a div if its inside one div and if not inside another one? for example like this

$( "#draggable" ).draggable({ revert: "valid", revert:"invalid" });

but that wouldn’t work because of obvious reasons.. can I condition that though?.. for when its inside this droppable and not inside of that droppable?

  • 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-22T16:09:56+00:00Added an answer on May 22, 2026 at 4:09 pm

    Your thinking was correct, you have to make the small boxes greedy droppables and handle the drop event on them. The tricky part is to cancel the drag operation.

    By default, your draggables should start as revert:'invalid'. You don’t have to do anything if they are dragged inside the big box, which in my example uses tolerance:'fit', so the small boxes must be completely inside to be accepted.

    I have made the small boxes greedy droppables with tolerance:'touch', so if the dragged small box touches another small box, it will call the drag handler on it.

    To cancel the drag operation from a drag handler, you can do a workaround of setting the dragged item to revert:true, which forces it to revert even though it was dropped on an accepting droppable. To make sure you can drag that small box again, on its drag stop event you have to reset revert:'invalid'. The stop event will fire on every successful drop and if it’s reverting, it will fire after reverting has completed.

    You can try out a live demo here: http://jsfiddle.net/htWV3/1/

    HTML:

    <div class="drop">
        <div class="drag"></div>
        <div class="drag"></div>
        <div class="drag"></div>
        <div class="drag"></div>
        <div class="drag"></div>
    </div>
    

    CSS:

    .drop { display:inline-block; width:300px; height:200px; border:1px solid silver; background-color:whitesmoke; padding:10px; }
    
    .drag { display:inline-block; width:30px; height:30px; border:1px solid silver; background-color:white; }
    

    Javascript:

    $('.drop').droppable({
        tolerance: 'fit'
    });
    
    $('.drag').draggable({
        revert: 'invalid',
        stop: function(){
            $(this).draggable('option','revert','invalid');
        }
    });
    
    $('.drag').droppable({
        greedy: true,
        tolerance: 'touch',
        drop: function(event,ui){
            ui.draggable.draggable('option','revert',true);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this standard example http://jqueryui.com/demos/sortable/#connect-lists-through-tabs <script> $(function() { $( #sortable1, #sortable2 ).sortable().disableSelection(); var $tabs
On Jquery UI's site: http://jqueryui.com/demos/draggable/ If I have: <div id=someId class=someClass>he</div> <div id=otherId class=otherClass>he2</div>
I've slightly extended the jQueryUI example Draggable + Sortable ( http://jqueryui.com/demos/draggable/sortable.html ) to make
So I've been working with this example: http://jqueryui.com/demos/draggable/#sortable and I've accomplished it on my
I'm trying to develop a simple shopping cart and using http://jqueryui.com/demos/droppable/#photo-manager as the base.
I am using jQuery UI; Draggable http://jqueryui.com/demos/draggable invoked like this: $(document).ready(function(){ $(#side_bar).sortable({ revert: true
I'm trying to mix a little those two samples ( http://jqueryui.com/demos/sortable/connect-lists.html ) and (
I have this simple example where I am working with jQuery UI Draggable/Droppable http://www.andrewherrick.com/spike/dragme/
I am using the jQuery UI Draggable/Sortable demo (http://jqueryui.com/demos/draggable/#sortable) for the basis of my
This is my code taken from http://jqueryui.com/demos/draggable/ <!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8>

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.