Kristjan Kirpu
Kristjan Kirpu

Reputation: 682

Detect if sortable has been dragged out of container

I would like to detect when a sortable item has been dragged out of the container (or has been dropped outside of the container) so I can call a function if it has been selected and dropped inside the same container class.

Jsfiddle

http://jsfiddle.net/u3TH4/5/

$(".container").sortable({
    connectWith: ".button",
    tolerance: "pointer",
    stop: function(event, ui) {
        if(!not-dragged-outside-of-container) {
            // a function here
        }
    }
});

$(".button").sortable({
    connectWith: ".container",
    tolerance: "pointer"
});

Upvotes: 1

Views: 1778

Answers (1)

rgrwkmn
rgrwkmn

Reputation: 159

Use the receive and remove callbacks. The item is in the ui object passed as the second argument: http://api.jqueryui.com/sortable/#event-remove

Upvotes: 1

Related Questions