jQuery – Modify Primefaces Radiobutton

Updating Primefaces radiobutton using javascript is tricky.

Below code can be used to enable or clear a particular radio button.

enableRadioButton($(“[id*=’RADIOFIELDNAME:0′]”));
clearRadioButton($(“[id*=’RADIOFIELDNAME:1′]”));

function enableRadioButton(obj)
{

var a = obj.parent();
obj.prop(“checked”, true);
a.parent().children(‘.ui-radiobutton-box’).addClass(
“ui-state-active”).children(“.ui-radiobutton-icon”)
.addClass(“ui-icon-bullet”).removeClass(
“ui-icon-blank”);
}
function clearRadioButton(obj)
{
var a = obj.parent();
obj.prop(“checked”, false);
a.parent().children(‘.ui-radiobutton-box’).removeClass(
“ui-state-active”).children(“.ui-radiobutton-icon”)
.removeClass(“ui-icon-bullet”).addClass(
“ui-icon-blank”);

}

Advertisements