Hi! I have a list of items and it implements sortable. I want the specified item to be removed when the user checks the checkbox in the list and clicking on remove. Here is the code:
How do I get the old and new position of the item dragged? I need the position so that I can do sorting of some data associated with it. I can’t use the id because in the list of items, there can be duplicate ids.
This is what I have tried:
$("#sortable").sortable({start:posStart,stop:posStop});
var posStart = function(e, ui) {
el = e.target;
var index = $(this).children('li').index(el);
$("#old").text(index);
}
var posStop = function(e, ui) {
el = e.target;
var index = $(this).children('li').index(el);
$("#new").text(index);
}
Problem is I always get -1 for the old and new positions. Please help. Thanks.