Hi Will,

It would be easy with the button inside the list but what I am trying
to achieve is to drag a sortable item into a bin (div) which is
droppable so when it drops, I want to delete that particular item from
the sortable list. Hence I tried iterating through the sortable list
and deleting the item with the same id that was dropped.

Cheers

On Dec 11, 11:56 pm, Will Kelly <[email protected]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to