<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments for Joe Lanman</title>
	<atom:link href="http://www.joelanman.com/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://www.joelanman.com</link>
	<description>web development when not playing computer games</description>
	<pubDate>Mon, 15 Mar 2010 06:37:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>Comment on IE Bug: Fading animation makes text render without anti-aliasing by Gustavo Tandeicarz</title>
		<link>http://www.joelanman.com/archives/15#comment-63</link>
		<dc:creator>Gustavo Tandeicarz</dc:creator>
		<pubDate>Fri, 26 Feb 2010 20:07:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=15#comment-63</guid>
		<description>bookmarked. 
awesome.</description>
		<content:encoded><![CDATA[<p>bookmarked.<br />
awesome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Uploading images and making thumbnails with web.py and PIL by Shawn Hamman &#187; Python, Django and the bloody annoying error messages</title>
		<link>http://www.joelanman.com/archives/10#comment-60</link>
		<dc:creator>Shawn Hamman &#187; Python, Django and the bloody annoying error messages</dc:creator>
		<pubDate>Fri, 09 Oct 2009 20:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=10#comment-60</guid>
		<description>[...] the end, I found the reason and the solution on a blog by Joe Lanman (http://www.joelanman.com/archives/10): I was not closing the file before trying to re-size it. Yes, yes, I know, amateur hour, but the [...]</description>
		<content:encoded><![CDATA[<p>[...] the end, I found the reason and the solution on a blog by Joe Lanman (http://www.joelanman.com/archives/10): I was not closing the file before trying to re-size it. Yes, yes, I know, amateur hour, but the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Usable multiple-selection with checkbox lists and jQuery by Viktor</title>
		<link>http://www.joelanman.com/archives/11#comment-8</link>
		<dc:creator>Viktor</dc:creator>
		<pubDate>Fri, 10 Apr 2009 05:32:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=11#comment-8</guid>
		<description>Thanks for the reply!
I'm beginner in Web and JavaScript programming and tips :)</description>
		<content:encoded><![CDATA[<p>Thanks for the reply!<br />
I&#8217;m beginner in Web and JavaScript programming and tips <img src='http://www.joelanman.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Usable multiple-selection with checkbox lists and jQuery by admin</title>
		<link>http://www.joelanman.com/archives/11#comment-7</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Thu, 09 Apr 2009 08:55:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=11#comment-7</guid>
		<description>Hi Victor, thanks for the comment.

The problem with the code you posted is two-fold: it assumes the link already has the correct class for its state, and it flips the checkbox state based on the current state.

The problem with the first is that a lot of browsers try to maintain the state of the form on refresh. This means that if you tick some boxes and then refresh, the selected items would be ticked, but not have the correct class. With your code, if you then clicked, it would toggle to the wrong class again. The solution to this would be to make sure the items have the correct class when the page loads - I'll look into adding that.

The problem with the second is that we deal with two different events - clicking the link and clicking the checkbox itself. When you click the checkbox, it changes state automatically before this code gets run. Therefore if you simply toggle the state, it will toggle back to its original state. If you try using preventDefault(), the checkbox will still change state before the code is run, the code will toggle it off again, and then the preventDefault() runs, also turning it off (preventing the default behaviour) so it doesn't help. This is why I treat the link and the checkbox event separately and pass the desired state to applyChecked().

If we implement the class checking on page load as I mentioned earlier, then the following code should work:

$link.toggleClass(’selected’);
$checkbox.attr(’checked’, checked);</description>
		<content:encoded><![CDATA[<p>Hi Victor, thanks for the comment.</p>
<p>The problem with the code you posted is two-fold: it assumes the link already has the correct class for its state, and it flips the checkbox state based on the current state.</p>
<p>The problem with the first is that a lot of browsers try to maintain the state of the form on refresh. This means that if you tick some boxes and then refresh, the selected items would be ticked, but not have the correct class. With your code, if you then clicked, it would toggle to the wrong class again. The solution to this would be to make sure the items have the correct class when the page loads - I&#8217;ll look into adding that.</p>
<p>The problem with the second is that we deal with two different events - clicking the link and clicking the checkbox itself. When you click the checkbox, it changes state automatically before this code gets run. Therefore if you simply toggle the state, it will toggle back to its original state. If you try using preventDefault(), the checkbox will still change state before the code is run, the code will toggle it off again, and then the preventDefault() runs, also turning it off (preventing the default behaviour) so it doesn&#8217;t help. This is why I treat the link and the checkbox event separately and pass the desired state to applyChecked().</p>
<p>If we implement the class checking on page load as I mentioned earlier, then the following code should work:</p>
<p>$link.toggleClass(’selected’);<br />
$checkbox.attr(’checked’, checked);</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Usable multiple-selection with checkbox lists and jQuery by Viktor</title>
		<link>http://www.joelanman.com/archives/11#comment-6</link>
		<dc:creator>Viktor</dc:creator>
		<pubDate>Thu, 09 Apr 2009 04:25:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=11#comment-6</guid>
		<description>Hi!

if (checked)
{
$link.addClass('selected');
$checkbox.attr('checked', true);
} else {
$link.removeClass('selected');
$checkbox.attr('checked', false);
}

==

$link.toggleClass('selected');
$checkbox.attr('checked', !($checkbox.attr('checked')));


?</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>if (checked)<br />
{<br />
$link.addClass(&#8217;selected&#8217;);<br />
$checkbox.attr(&#8217;checked&#8217;, true);<br />
} else {<br />
$link.removeClass(&#8217;selected&#8217;);<br />
$checkbox.attr(&#8217;checked&#8217;, false);<br />
}</p>
<p>==</p>
<p>$link.toggleClass(&#8217;selected&#8217;);<br />
$checkbox.attr(&#8217;checked&#8217;, !($checkbox.attr(&#8217;checked&#8217;)));</p>
<p>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Having cake and also eating it: Compiz and dual-head on an ATI HD 2600 by Johannes Müller</title>
		<link>http://www.joelanman.com/archives/7#comment-5</link>
		<dc:creator>Johannes Müller</dc:creator>
		<pubDate>Sat, 22 Nov 2008 17:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=7#comment-5</guid>
		<description>Thank you for this information! This is exactly what I was looking for and saved me a lot of time. Internet at its best :-)</description>
		<content:encoded><![CDATA[<p>Thank you for this information! This is exactly what I was looking for and saved me a lot of time. Internet at its best <img src='http://www.joelanman.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Python-style startswith and endswith string functions in Javascript by Chelsi</title>
		<link>http://www.joelanman.com/archives/4#comment-4</link>
		<dc:creator>Chelsi</dc:creator>
		<pubDate>Tue, 28 Oct 2008 17:50:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.joelanman.com/?p=4#comment-4</guid>
		<description>Well said.</description>
		<content:encoded><![CDATA[<p>Well said.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
