How do I get a draggable to revert to the original position only if it was dragged onto an invalid droppable?

I have an element I want to allow to be dragged anywhere. However, if it is dropped onto a droppable which refuses it (via accept) I want it to revert to the original position before the drag. How can I accomplish this?

EDIT: to be more specific: I want two conditions to be met in order for the item to be moved back: 1. It was dropped on a droppable and 2. The droppable didnt accept said item. Draggable's revert option only checks condition 2.


I have some code which I think should work. Note that it doesn't use the accept option to specify which draggables the droppables will accept. Instead, you'll have to check whether or not a draggable should be rejected manually, in the drop event.

$(document).ready(function() {
        drop: function(event, ui) {
            // check whether or not draggable should be rejected here...
            if (...) {
      'rejected', true);

        revert: false,
        start: function(event, ui) {
  'rejected', false);
  'original-position', ui.helper.offset());
        stop: function(event, ui) {
            if ('rejected') === true) {

Need Your Help

Multiple Image in Canvas ItemsControl

wpf xaml itemscontrol

I want to show multiple image on a canvas. I need to position them differently in the canvas. I made a class for my images :

LINQ to SQL: Multiple / Single .dbml per project?

linq visual-studio linq-to-sql

I've read Rick Strahl's article on Linq to SQL DataContext Lifetime Management hoping to find some answers on how I would manage my .dbml files since they are so closely related to DataContext.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.