1

Currently I am using the toggle() to change the split button icon to 'X' data-split-icon ="delete", but after I change the icon, I want to add an event handler to actually delete the list item. I tried this example for stackexchange but I am not sure what I am doing wrong.

Since I can't find a lot of help on this topic, is there a better way/best practice UI pattern to delete items from a list?

Here is my code so far: http://jsfiddle.net/N7Z9e/1006/

1 Answer 1

3

This should work:

$("#listview li .ui-li-link-alt").live("click",function(){
        $(this).parent("li").remove();
});

A demo here - http://jsfiddle.net/gDea8/

Let me know if that helps.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much, I liked the way you selected the class teaching wise. jQuery says not to use the .live() and to use the .delegate()? So on my dev machine I made http://jsfiddle.net/gDea8/9/ but it's not working jsfiddle. Is it a okay practice to do it this way?
Whoops no it's .on() so I changed delegate to .on(). Works fine too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.