0

I try reproduce this example with Jquery Mobile 1.3.2, but it works only with version 1.2.1 or less.

    $(document).on("pageinit", "#page1", function(){

        $("#checkFirst").click(function(){
            $("input[type='radio']:first").attr("checked", "checked");
            $("input[type='radio']").checkboxradio("refresh");
        });
        $("#checkSecond").click(function(){
            $("input[type='radio']:eq(1)").attr("checked", "checked");
            $("input[type='radio']").checkboxradio("refresh");
        });
        $("#checkLast").click(function(){
            $("input[type='radio']:last").attr("checked", "checked");
            $("input[type='radio']").checkboxradio("refresh");
        });
        $("#uncheckAll").click(function(){
            $("input[type='radio'][checked]").removeAttr("checked");
            $("input[type='radio']").checkboxradio("refresh");
        });
    });

This function redraw radiobuttons only 1st time for one radiobutton in jqm > 1.2.1

this links to jsfiddle:

Works version with 1.2.1
Don't works version with 1.3.2

Any ideas why this examples don't work in other versions?

Community
  • 1
  • 1
D dr
  • 31
  • 1
  • 4

2 Answers2

1

use .prop() instead of .attr()

//to check
$("input[type='radio']:first").prop("checked", true);
//to uncheck
$("input[type='radio']:first").prop("checked", false);

Read: Properties Vs Attributes

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
0

Use .prop() instead of .attr()

$("input[type='radio']:first").prop("checked", true);

Read .prop() vs .attr()

Community
  • 1
  • 1
Satpal
  • 132,252
  • 13
  • 159
  • 168