Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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/

like image 696
pahnin Avatar asked Jun 07 '26 04:06

pahnin


1 Answers

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

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

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

like image 75
undefined Avatar answered Jun 10 '26 05:06

undefined



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!