javascript - jQuery UI Dialog, Checkboxes and the mysterious case of IE6 -
i have jquery ui dialog containing checkboxes. want conditionally set state of these checkboxes , open dialog.
unfortunately causes problems in ie6. checkbox never checked if it's value set before opening dialog.
for example in following code "dialog checkbox 1" never checked in ie6, in every other browser.
[update] problem how ie6 resets state of checkbox appended anywhere. , when dialog opened, jquery ui appends top of body. apparently "it's known fact when working ie, checked state of checkboxes lose state when appended [anywhere]" (see link below)
this jquery forum post suggests resolution concerned changing jquery ui code; i'd rather not if @ possible.
are there solutions this?
thanks,
d.
code:
<script type="text/javascript"> $(document).ready(function() { $('#dialog').dialog({ autoopen : false, modal : true }); $("a#opendialog").click(function() { $("#formcontainer .check1").attr("checked", true); $('#dialog').dialog('open'); $("#formcontainer .check2").attr("checked", true); }); }); </script> <h1>jquery dialog/checkbox test</h1> <a href="#" id="opendialog">open dialog</a> <div id="dialog"> <form> <div id="formcontainer"> dialog checkbox 1: <input type="checkbox" value="blue" class="check1"/> dialog checkbox 2: <input type="checkbox" value="red" class="check2"/> </div> </form> </div>
always loathe answer own question i've found workaround else find useful if hit this.
use "defaultchecked" attribute instead of "checked" when setting before opening dialog. eg:
$("a#opendialog").click(function() { $("#formcontainer .check1").attr("defaultchecked", true); $('#dialog').dialog('open'); $("#formcontainer .check2").attr("checked", true); });
note "defaultchecked" after open not check it. safer use both if code may move.
Comments
Post a Comment