Reputation: 53866
Is it possible to allow a new div that is added dynamically to a dom to be made droppable ?
I'm trying this :
var myDroppable = '<div id="myDroppableDiv" >New droppable</div>';
$("#myDroppables").append(myDroppable );
But receive this error :
Object has no method 'droppable'
Upvotes: 1
Views: 418
Reputation: 92953
Just invoke the droppable
method as soon as its appended:
$(myDroppable).appendTo('#myDroppables').droppable();
Upvotes: 4
Reputation: 253396
Yep; you can do it this way:
var d = $('<div />').droppable();
d.appendTo('body');
Upvotes: 1