I have my screen divided into two DIV
s. In the left DIV
I have a few 50x50 pixel DIV
s, in the right DIV
I have an empty g
based on Barry's code, what if we d like to add an option with an "x" button the element to be detached again from the new parent and be reattached to the initial?
i thought sth like this, but didn't seem to work.. to make some sort of a variable that hold initial state
var flag;
$('.draggable-div').draggable({
revert: 'invalid',
stop: function(){
$(this).draggable('option','revert','invalid');
$(this).find('.undo').show();
flag=$(this).parent();
}
});
$('.draggable-div').find('.undo').click(function(i, e) {
var $div = $(this).parent();
$($div).detach().appendTo(flag);
}
sth is definately wrong but i don't know if you can get the concept... just being able to reverse whatever you have dropped to their initial state.