Hadi Mostafavi
Hadi Mostafavi

Reputation: 75

JQuery UI 1.10.3 Sortable not removing items

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.

enter image description here

And here is the annoying placeholdenter image description hereer

Upvotes: 1

Views: 339

Answers (1)

user2314737
user2314737

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

Related Questions