0

I have a problem with jQueryUI and the draggable/droppable options.

What I want to accomplished is this:

1) Drag an element into another one 2) Once the element its there, revert the draggable element to its initial state (and do some other stuff)

I can revert the object to its initial state by doing this:

revert : function(event, ui) {
      B(this).data("draggable").originalPosition = {
          top: 0,
          left: 0
      };
      return !event;
}

But I want to revert the element even and when it is dragged into the correct place...

EDIT

I have tried this:

B('#template').find('section').droppable({
  drop : function(e, ui) {
    ui.draggable.triggerHandler('revert');
  }
}

But it is not working... I have also tried to get the option and execute it, but it is also not working.

Erwin
  • 4,757
  • 3
  • 31
  • 41
Cito
  • 1,659
  • 3
  • 22
  • 49

1 Answers1

0

If you always want to revert, just return true in your revert function

malificent
  • 1,441
  • 14
  • 18
  • Thanks a lot! That works. Is there any documentation about it? I couldn't find anything in the documentation at jqueyrui, actually, I found the revert event googling for this. Thanks a lot! – Cito Sep 28 '12 at 23:11
  • http://jqueryui.com/demos/draggable/#option-revert you actually don't need to define the anonymous function...you can just set the revert option to true. $("#dragme").draggable({revert:true}) – malificent Sep 28 '12 at 23:15