Hi, I have found some issues in how jQuery 1.3.1 handles checkboxes in
XHTML.  I created the following PHP sample based on jQuery FAQ 1.7:

------------
<?php
header('Content-type: application/xhtml+xml');
print '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Checkbox test</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js";>
</script>
</head>
<body>
<p>
<input type="checkbox" id="c"/> I'll be checked/unchecked.
<input type="button" value="Check"
onclick='$("#c").attr("checked","checked")'/>
<input type="button" value="Uncheck"
onclick='$("#c").removeAttr("checked")'/>
</p>
</body>
</html>
------------

If you click the buttons, jQuery 1.3.1 changes the state of the
checkbox.  But if you click directly on the checkbox, then jQuery
1.3.1 does not change the state of the checkbox.  For example, if you
click on the checkbox to set it, the Uncheck button cannot clear it,
and if you unclick on the box to clear it, the Check button cannot set
it.  This problem occurs in Firefox 3.0.5, Safari 3.2.1, and Google
Chrome 1.0.  jQuery 1.3.1 does work properly in Opera 9.63.  I'll get
to IE in a moment.

jQuery 1.2.6 works correctly, so I compared the source and discovered
that jQuery 1.3.1 correctly identifies the page as XML (XHTML), while
jQuery 1.2.6 does not.  Within attr(), the value of var notxml = !
jQuery.isXMLDoc( elem ) determines how jQuery sets the element
attribute.  If notxml is true, jQuery is setting the checked attribute
correctly, but if notxml is false, then jQuery does not set or clear
the checkbox once someone clicks directly on the checkbox.

As a workaround, I have found that I can set and clear the checkbox by
setting the DOM property directly:

        document.getElementById("c").checked = false;
        document.getElementById("c").checked = true;

However, Opera seems to understand when jQuery sets the checked
attribute.

Now, IE6 and IE7 cannot accept Content-type: application/xhtml+xml, so
I send the more traditional Content-type: text/html.  Thus, with IE6
and IE7, jQuery 1.3.1 reverts back to the behavior of 1.2.6, so IE
works.

Sorry for the amount of detail here, but I hope this will be helpful
in fixing this problem.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to