Search code examples
jqueryjquery-uidraggable

jQuery UI draggable not working with dynamically created divs


I have included jquery-1.7.2.min first and then jquery-ui-1.8.21.custom.min

then I have dynamically created divs with a class name and I called draggable and selectable on them but it is not working. in dom ready

   $.each(a, function (l, i) {
       $('.browser').append("<div class='folder' id=" + i + "></div>");
   });
   $('.folder').selectable().draggable();

Here is the fiddle link http://jsfiddle.net/2Nh5m/


Solution

  • just reverse the order of calling draggable() and selectable() and it will work:

    $('.folder').draggable().selectable() 
    

    http://jsfiddle.net/2Nh5m/1/