user894723
user894723

Reputation: 3

jQueryUI Draggable: Error with dynamically added element

I've slightly extended the jQueryUI example "Draggable + Sortable" ( http://jqueryui.com/demos/draggable/sortable.html ) to make it able to add draggable elements dynamically. Live example can be found here: http://jsfiddle.net/MLSqa .

After click the Add button the new draggable item gracefully added to the #sortable list.

But. When try to move it by mouse (1st time) it suddenly jumps to the top-left corner. And only 2nd attempt to move it gets success.

How to fix such strange behavior? How to drag the newly added item correctly?

Upvotes: 0

Views: 1339

Answers (1)

321X
321X

Reputation: 3185

Check the update: http://jsfiddle.net/MLSqa/1/

You don't have to 'recreate' a draggable on the new item. Just add the new item to the already existing draggable.

I also removed the $ in front of the variable box. You can put this back if you want to.

Upvotes: 2

Related Questions