1

I have been successful in adding list items of <li> to a unordered list ul. But now it seems I am having trouble adding checkbox items to a list which is within one <li>. In my jsfiddle below

  1. I empty the list
  2. Append to the list
  3. Refresh the list to add the jqm class styles

Again this has worked in the past for adding list items to a list.I am sure my syntax is just wrong.

http://jsfiddle.net/N7Z9e/1112/

2 Answers 2

1

This line:

$("#ulTest").listview("refresh")

Should change to:

$("#ulTest").listview("refresh").find('input').checkboxradio();

You have to initialize any widget that you add dynamically. Basically you're telling jQuery Mobile that you have added a widget and you want it to be styled. You were updating the listview widget but not initializing the new checkbox widgets.

Docs: http://jquerymobile.com/demos/1.1.0-rc.1/docs/forms/checkboxes/methods.html

Here is an updated version of your JSFiddle: http://jsfiddle.net/jasper/N7Z9e/1113/

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

Comments

0

Switch the binding method to just .click

$('#btnTest').click(function(e){
});

1 Comment

Yes that does fix the button event. I just put it there for this demo purposes. However, the real question is how to get newly inserted checkbox item styled with the jQuery classes.

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.