I have a sortable (made of nested <div></div>
) on my webpage. I would like that an item dragged out of the sortable be removed from the sortable.
But I can't get the "out" event to be triggered.
Here is my JS (inspired from this SO question):
$(function(){
var removeIntent = false;
$('#selectedTags').sortable({
over: function () {
removeIntent = false;
console.log("over: "+removeIntent);
},
out: function () {
removeIntent = true;
console.log("over: "+removeIntent);
},
beforeStop: function (event, ui) {
console.log("over: "+removeIntent);
if(removeIntent){
ui.item.remove();
}
}
});
});
You will find my jsFiddle here.
All help is welcome.
Edit: If I convert my divs to a <ul></ul>
it then works as planned. Any explanations there ? I would like to keep the <div></div>
though as I need the sortable to be horizontal.
Just checked your fiddle; it seems that the css
is what is actually causing the out not to be triggered. Just a pointer!