user471317
user471317

Reputation: 1231

Binding knockout array to render jqm radio buttons

I am trying to render a radio button list. I modified the code sample from this url and ended up with this piece of crap/code,

http://demos.jquerymobile.com/1.0a4.1/docs/forms/forms-radiobuttons.html

<fieldset data-role="controlgroup">
    <legend>Choose a pet:</legend>
        <!-- ko foreach: pets -->
            <input type="radio" name="radio1" data-bind="value: id, checked: $root.selectedID, attr: {'id': 'radio-1' + $index() }" />
            <label data-bind="attr: {'for': 'radio1' + $index() }, text: name"></label>
        <!-- /ko -->
</fieldset>

I don't know what I am doing wrong. I see in the rendered html, the div (with class ui-radio) surrounds just the input, the label is outside the div. And the resulting radio button list is completely out of format.

What am I doing wrong?

Thanks.

Upvotes: 0

Views: 74

Answers (1)

Jeremy Danyow
Jeremy Danyow

Reputation: 26406

you'll need to tell jquery mobile to enhance these manually. Here's how to do that:

$('[type="radio"]').checkboxradio();

https://stackoverflow.com/a/14550417/725866

Upvotes: 1

Related Questions