opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Widget checkboxradio buttons do not respond when used with type "radio" #143

Closed rodcloutier closed 11 years ago

rodcloutier commented 11 years ago

Selecting the buttons does not update the model or trigger the radio group behaviour.

Changing the model binding updates the radio group but only if a button has not been pressed.

See the following fiddle http://jsfiddle.net/ZHKBA/119/

tbosch commented 11 years ago

Hi, there are two problems in your example:

  1. There is no name attribute on the first set of radio buttons. By this, jqm does not know that they belong together, and that's the reason why the stay pressed.
  2. As ng-repeat creates a nested scope for every radio button, and you want to change the property value of the parent scope, you have to use ng-model="$parent.value" instead of ng-model="value". Skipping the $parent works fine for reading, as nested scopes inherit from parents, but not for writing, as then the property value is created in the nested scope.

Together, your input needs to look like this:

<label ng-repeat="l in values">{{l.label}}
                <input type="radio" name="radio-choice-h-1" ng-model="$parent.value" value="{{l.value}}">
</label>

Here is a corrected jsfiddle that works: http://jsfiddle.net/tigbro/ZHKBA/121/

Closing this as not a bug... Tobias

rodcloutier commented 11 years ago

Thanks Tobias makes a lot of sense now that I see it...