0

I want to be able to drag events to empty divs here.

Here's my fiddle: http://jsfiddle.net/Yc9WY/6/

If you drag an event to an empty div, you'll see that it does not eliminate the first one, and I can no longer drag the newly appended href to a new div.

What am I missing?

Jason Wells
  • 887
  • 6
  • 16
  • 33
  • I see you are checking the dropped div to make sure there isn't an event already. If there isn't one you are appending another draggable, which creates a duplicate. Is this the intent and you want to be able to drag the original event again? – Ryan Fiorini Apr 26 '12 at 00:49
  • I changed the if check a little and it is moving the dive to the new div and is draggable again. I have a problem with the position after. I will look further and let you know. http://jsfiddle.net/ryanwfiorini/tYrM2/ – Ryan Fiorini Apr 26 '12 at 01:04
  • I updated my jsfiddle now so it moves the event to the correct div and corrects the css now. I also add a revert, so if you drop an event on a div that already has an event it moves it back to the original div. – Ryan Fiorini Apr 26 '12 at 01:21

1 Answers1

1

Instead of creating a new anchor and cloning the data inside the dragged element, why don't you just move the element itself?

$(this).append(ui.draggable);

You'll also need to reset the position to remove the left/top properties that draggable adds (there's probably a function/option for this, but you can look around the docs).

Example: http://jsfiddle.net/Yc9WY/27/

Christian
  • 19,605
  • 3
  • 54
  • 70