I'm going to say for performance reasons, I use instead:
$('.draggable:not(.ui-draggable)').draggable();
This will prevent attempts to reinitialize already draggable items using the jQuery UI built into the class. In addition, if your code changes the properties of a single draggable object along the way, which may not correspond to the properties of a new draggable object, you may end up resetting with someone.
There is nothing wrong with being specific with jQuery.
UPDATE
Did not indicate for which instance to use this. Based on Ricardo Edit:
$(function() { $( ".draggable" ).draggable(); $('.content').click(function(){ var htmlData='<div class="draggable ui-widget-content"><p>Drag me around</p></div>'; $('.demo').append(htmlData); $('.draggable:not(.ui-draggable)').draggable();
I also see that you manually added the ui-draggable class. You do not need to do this. In fact, this does what I said does not work.
Kyle Macey Jan 18 '12 at 1:11 2012-01-18 01:11
source share