I am passing an Array to a function that is supposed to check/uncheck some checkbox within a jQuery dialog.
function preCheck(boolArray){
$("#cb0").attr("checked", boolArray[0]);
$("#cb1").attr("checked", boolArray[1]);
$("#cb2").attr("checked", boolArray[2]);
$("#cb3").attr("checked", boolArray[3]);
//etc.
$("#divform").dialog("open");
}
Those checkbox are placed in the divform which is delcared as dialog in the document.ready function. The value inside boolArray is defined by which button I click to open the dialog (resulting in different checkbox being checked depending on which button was clicked).
My issue is the following : the first time a button is clicked, the checkbox are checked accordingly to the boolArray. If I check/uncheck some manually > close the dialog > reclick on the same button to open the dialog, the checkbox remain in the state they were before I closed the dialog and no longer are checked/unchecked according to boolArray's value. Even more frustrating, the one that I unchecked and that should be checked (according to the boolean in boolArray) appear in the HTML as checked="checked"
even though there are no tick marks. Any help would be appreciated, I'm truly lost.