This doesn't work with jQuery 1.9
$("#" + IDProduct).attr("checked", "checked").checkboxradio("refresh");
This doesn't work with jQuery 1.9
$("#" + IDProduct).attr("checked", "checked").checkboxradio("refresh");
to check it
$("#" + IDProduct).prop("checked", true).checkboxradio("refresh");
to un-check it
$("#" + IDProduct).prop("checked", false).checkboxradio("refresh");
According to jQuery docs 1.9 version :
.checkboxradio("refresh");
is a jQuery mobile function so if you try to run it on an app that doesn't have jQuery mobile and is a jQuery only app it won't work.
Another thing I have noticed is that in many cases when you use .attr("checked",false) you will not be able to use .attr("checked",true)
or .attr("checked","checked")
afterwards on the same checkbox group .. this is just from personal experience
If you are using jQuery only then use .prop as RolandoCC has mentioned but keep in mind the checkboxradio does NOT work on jQuery checkboxes, ONLY on jQuery mobile specific items
** EDIT **
Another Tip that I can provide (this worked for me recently when ("checked",false) was breaking my checkboxes is to FIRST do ("checked",true) on the item that should be checked and only once that is checked to do ("checked",false) on the item you want to uncheck.. this way you can at least get the correct one checked
For example instead of doing:
$("#box1").attr("checked", false).checkboxradio("refresh");
$("#box2").attr("checked", true).checkboxradio("refresh");
do:
$("#box1").attr("checked", true).checkboxradio("refresh");
$("#box2").attr("checked", false).checkboxradio("refresh");
I am personally not sure why a checked false breaks any subsequent check true but maybe a bug needs to be logged against this.. good luck guys
to check it
$("#" + IDProduct).prop("checked", true).checkboxradio("refresh");
to un-check it
$("#" + IDProduct).prop("checked", false).checkboxradio("refresh");
status
$("#" + IDProduct).prop("checked") true/false
According to jQuery docs 1.7.1 version :