JQuery Live and draggable event with elements created on the fly

Written: Dec 7th 2009, 22:20

Draggable and Droppable in jQuery UI is very handy, but if you are adding new draggable items to your DOM tree on the fly, they will not work since the events is binded when the document is created. jQuery Live comes to rescue, but how do you use it jQuery.live?

The answer is to add the draggable behavior when the user first mouse over the item. To avoid binding the behavior twice we a init check:

Back to posts list