Hi, your jQuery code above will only run once if you're calling it on
the UL etc, try it like this
$("ul#list > li").each(function(index,domEl) {
//etc
}
If you're only trying to delete one item you could have the delete
button within the li which would make it easier
//called before .sortable();
$("ul#list > li > input.delete").click(function() {
$(this).remove();
$("ul#list").sortable('refresh');
}
$("ul#list").sortable();
Hope that helps!
Will
On Dec 11, 8:05 am, quangas <[EMAIL PROTECTED]> wrote:
> 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??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---