Remove Items from Sortable list or remove LI item from UL list
Does anyone have any idea how to delete an item from a Sortable list?
With the extra placeholder item in there, it seems to get confused on
what item to delete.
I've tried several ways to delete an item from the Sortable list and
the closest I got was to use the following bit of code but again, the
index sometimes isn't correct so the item doesnt get deleted or
doesn't delete altogether. This however only works in IE.
$(listname).each(function(j, item) {
if(ui_id == item.id)
{
var sort_str = "." + parent_class + "
li:nth-child(" + j + ")";
$(sort_str).remove();
}
});
I have also tried getting the list item with a specific id, and
perform a remove but that doesn't seem to work.
e.g. $("#list_item_id).remove(); // not sure why this doesn't work
I have also tried getting the parent and removing its child without
jquery
var elems = document.getElementById('things_list');
for(var i=0; i<elems.childNodes.length; i++)
{
if(elems.childNodes[i].id == ui_id)
{
elems.removeChild(elems.childNodes[i]);
break;
}
I am out of ideas.
Surely it cannot be that difficult to delete an LI item from a UL
list??