Tag Archives: JQuery Mobile Checkbox

JQuery Mobile: Checkbox Issue

I have been trying to manipulate checkbox via JavaScript.
Long time spent to find out why the regular JQuery Code doesn’t work with JQuery Mobile.
Finally I resolved the issue.
Review the code below to understand the solution.

[javascript]
$(‘input.credits[chk="chk"]‘).attr(‘selected’,'selected’).checkboxradio("refresh");
[/javascript]

The code

.checkboxradio("refresh");

must be added every time the checkbox value changed.

PS Note:
Same rule probably should be applied to select element in jQuery Mobile Framework

[javascript]
$(‘.province_select’).attr(‘name’,'bill_province_2′).selectmenu(‘refresh’,true);
[/javascript]

One more snippet regarding this matter

[javascript]
$(‘select#provinces’).val(‘somevalue’).selectmenu(‘refresh’);
[/javascript]