I am trying to clone a resizable and draggable div, but it does not work properly ...
This is my actual HTML code:
<div class="resizable" class="ui-widget-content"> <div class="menuTrigger"></div> <ul> <li class="clone">Clone</li> <li class="remove">Remove</li> </ul> </div>
And this is my real jQuery code:
function initialize(that){ $(that).resizable({ handles: 'n, e, s, w, ne, se, sw, nw' }); $(that).draggable({ stack: "div", distance: 0 }); $(that).find(".clone").click(function(){ var $clone = $(this).parents('.resizable').clone(); var offset = $(this).parents('.resizable').offset(); $('body').append($clone); initialize($clone); }); $(that).find(".remove").click(function(){ $(this).parents('.resizable').remove(); }); $(that).find(".menuTrigger").click(function(){ $(this).parent().find('ul').toggle(); }); } $(".resizable").each(function(){ initialize($(this)); });
Demo
user3542686
source share