Friday, July 6, 2012

jQuery single draggable in droppable

jQuery UI is a library that works with jQuery which allows you to easily drag and drop elements.

However, sometimes when you have more draggables and wish to let only one reside inside a droppable, you may need to take actions.

Here is some self explaining code that does just that:

  opacity: 0.35,
  revert: true,
  snap: true,
  zIndex: 2800

  greedy: true,
  drop: function(e, ui) {
    $(this).droppable('option', 'accept', ui.draggable);
  out: function(e, ui) {
    $(this).droppable('option', 'accept', '.item');

1 comment: