Reputation: 75
I'm using a sortable div of images, but i'm not able to remove the item when it gets dragged out of the div.
var sortableIn = false;
$("#divId").sortable({
over: function () {
sortableIn = false;
},
out: function () {
sortableIn = true;
},
beforeStop: function () {
if (sortableIn == true) {
ui.item.remove();
}
},
}).disableSelection();
I have also tried $(div.img) with the remove method in the beforeStop function I know $(div.img) is not correct but it does seem to remove the annoying placeholder that was popping up. var newItem = ui.item; also didnt do the trick.
And here is the annoying placeholder
Upvotes: 1
Views: 339
Reputation: 29317
This seems to work. http://jsfiddle.net/hdmZY/
I used
var sortableIn = false;
$('#divId').sortable({
over: function () {
sortableIn = false;
},
out: function (event, ui) {
sortableIn = true;
},
beforeStop: function(event, ui) {
if (sortableIn == true) {
ui.item.remove();
}
}
}).disableSelection();
Upvotes: 1