<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Writing better jQuery Code</title>
	<atom:link href="http://query7.com/writing-better-jquery-code/feed" rel="self" type="application/rss+xml" />
	<link>http://query7.com/writing-better-jquery-code</link>
	<description>jQuery Programming &#124; Flex Development &#124; Zend Coding &#124; AIR Development &#124; PHP Development</description>
	<lastBuildDate>Tue, 09 Mar 2010 03:56:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Louis-Guillaume Carrier-Bédard</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-393</link>
		<dc:creator>Louis-Guillaume Carrier-Bédard</dc:creator>
		<pubDate>Thu, 16 Oct 2008 21:16:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-393</guid>
		<description>Thanks for this tutorial. Thanks to Peter Bex for his great comments.</description>
		<content:encoded><![CDATA[<p>Thanks for this tutorial. Thanks to Peter Bex for his great comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-391</link>
		<dc:creator>Max</dc:creator>
		<pubDate>Mon, 13 Oct 2008 13:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-391</guid>
		<description>hi, great tu, thanks! but one question: how do i solve the problem to have just one unique id... cheers!</description>
		<content:encoded><![CDATA[<p>hi, great tu, thanks! but one question: how do i solve the problem to have just one unique id&#8230; cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Ni</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-389</link>
		<dc:creator>Bill Ni</dc:creator>
		<pubDate>Thu, 18 Sep 2008 07:42:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-389</guid>
		<description>Great Tutorial for a beginner like me .
Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Great Tutorial for a beginner like me .<br />
Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Muhammad Hussein Fattahizadeh</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-376</link>
		<dc:creator>Muhammad Hussein Fattahizadeh</dc:creator>
		<pubDate>Mon, 15 Sep 2008 23:22:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-376</guid>
		<description>great tutorial but has been better that have a live demo.
Good luck.</description>
		<content:encoded><![CDATA[<p>great tutorial but has been better that have a live demo.<br />
Good luck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ranjith</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-373</link>
		<dc:creator>Ranjith</dc:creator>
		<pubDate>Thu, 11 Sep 2008 06:47:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-373</guid>
		<description>Good Tutorial for a beginner like me.

I would be great if we discuss on all UI Components in Jquery like this.

Thanks a lot guys .Especially to Peter Bex for giving a much clean way...</description>
		<content:encoded><![CDATA[<p>Good Tutorial for a beginner like me.</p>
<p>I would be great if we discuss on all UI Components in Jquery like this.</p>
<p>Thanks a lot guys .Especially to Peter Bex for giving a much clean way&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vuli3eyou</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-388</link>
		<dc:creator>vuli3eyou</dc:creator>
		<pubDate>Fri, 22 Aug 2008 03:47:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-388</guid>
		<description>Great tutorial~~
Help me more understand on JQuery as a beginner.

Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Great tutorial~~<br />
Help me more understand on JQuery as a beginner.</p>
<p>Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olle Lundberg</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-387</link>
		<dc:creator>Olle Lundberg</dc:creator>
		<pubDate>Wed, 20 Aug 2008 09:48:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-387</guid>
		<description>@Panzer
While both ways work it is just stupid to concatenate an empty string. If you want to add nothing to it why add it? It doesn&#039;t matter if it has a small performance hit in this case if you do it once, you will most definately do it again and if you have several unnecessary string concatenations you are building your way to big performance issues. It is also considered bad practice.

You might also want to take a look on event delegation in jquery:
http://dev.distilldesign.com/log/2008/jan/27/event-delegation-jquery/
http://www.danwebb.net/2008/2/8/event-delegation-made-easy-in-jquery</description>
		<content:encoded><![CDATA[<p>@Panzer<br />
While both ways work it is just stupid to concatenate an empty string. If you want to add nothing to it why add it? It doesn&#8217;t matter if it has a small performance hit in this case if you do it once, you will most definately do it again and if you have several unnecessary string concatenations you are building your way to big performance issues. It is also considered bad practice.</p>
<p>You might also want to take a look on event delegation in jquery:<br />
<a href="http://dev.distilldesign.com/log/2008/jan/27/event-delegation-jquery/" rel="nofollow">http://dev.distilldesign.com/log/2008/jan/27/event-delegation-jquery/</a><br />
<a href="http://www.danwebb.net/2008/2/8/event-delegation-made-easy-in-jquery" rel="nofollow">http://www.danwebb.net/2008/2/8/event-delegation-made-easy-in-jquery</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Bex</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-386</link>
		<dc:creator>Peter Bex</dc:creator>
		<pubDate>Tue, 19 Aug 2008 08:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-386</guid>
		<description>Eek, the styling is off (code has black letters, but here&#039;s a black background). You can see the code by selecting it.

A &#039;preview comment&#039; function would be nice ;)</description>
		<content:encoded><![CDATA[<p>Eek, the styling is off (code has black letters, but here&#8217;s a black background). You can see the code by selecting it.</p>
<p>A &#8216;preview comment&#8217; function would be nice <img src='http://query7.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Bex</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-385</link>
		<dc:creator>Peter Bex</dc:creator>
		<pubDate>Tue, 19 Aug 2008 08:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-385</guid>
		<description>How about the following?

&lt;code&gt;
$(&#039;#langs li&#039;).click(function() {
    $(&quot;#container div&quot;).hide();
    var index = $(&#039;#langs&#039;).index(this);
    $(&quot;#container div&quot;).get(index).fadeIn(&quot;slow&quot;);
});
&lt;/code&gt;

It saves you from having to assign so many IDs. This also makes it easier if the HTML is generated by some CMS, so you don&#039;t have to hack the code to output IDs.

Of course, it&#039;ll only work if order of the list of links corresponds exactly to the divs like it is the case in this example.

Note it&#039;s not necessary to prefix your ID with div like &quot;div#container&quot;, if they&#039;re unique (and they must be unique or the HTML is invalid).</description>
		<content:encoded><![CDATA[<p>How about the following?</p>
<p><code><br />
$('#langs li').click(function() {<br />
    $("#container div").hide();<br />
    var index = $('#langs').index(this);<br />
    $("#container div").get(index).fadeIn("slow");<br />
});<br />
</code></p>
<p>It saves you from having to assign so many IDs. This also makes it easier if the HTML is generated by some CMS, so you don&#8217;t have to hack the code to output IDs.</p>
<p>Of course, it&#8217;ll only work if order of the list of links corresponds exactly to the divs like it is the case in this example.</p>
<p>Note it&#8217;s not necessary to prefix your ID with div like &#8220;div#container&#8221;, if they&#8217;re unique (and they must be unique or the HTML is invalid).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: &#8220;The Complete Guide&#8221; for jQuery Developer- Reblog &#171; Dynamic Disruption</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-384</link>
		<dc:creator>&#8220;The Complete Guide&#8221; for jQuery Developer- Reblog &#171; Dynamic Disruption</dc:creator>
		<pubDate>Tue, 19 Aug 2008 02:46:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-384</guid>
		<description>[...] Writing Better jQuery CodeLearn how to write better jQuery code to save your time and enjoy the process. [...]</description>
		<content:encoded><![CDATA[<p>[...] Writing Better jQuery CodeLearn how to write better jQuery code to save your time and enjoy the process. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2008-08-15</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-379</link>
		<dc:creator>links for 2008-08-15</dc:creator>
		<pubDate>Fri, 15 Aug 2008 14:31:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-379</guid>
		<description>[...] Writing Better jQuery Code &#124; Query7 - PHP jQuery Linux (tags: tutorial jquery javascript tutorials) [...]</description>
		<content:encoded><![CDATA[<p>[...] Writing Better jQuery Code | Query7 &#8211; PHP jQuery Linux (tags: tutorial jquery javascript tutorials) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Panzer</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-375</link>
		<dc:creator>Panzer</dc:creator>
		<pubDate>Fri, 15 Aug 2008 04:18:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-375</guid>
		<description>@Yura, Blancodan, Vish
Thanks alot!

@Joe Grossberg
Both ways work, won&#039;t be a big performance issue.

Thanks for the feedback guys, i&#039;ve updated the first post with better code.</description>
		<content:encoded><![CDATA[<p>@Yura, Blancodan, Vish<br />
Thanks alot!</p>
<p>@Joe Grossberg<br />
Both ways work, won&#8217;t be a big performance issue.</p>
<p>Thanks for the feedback guys, i&#8217;ve updated the first post with better code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blancodan</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-383</link>
		<dc:creator>blancodan</dc:creator>
		<pubDate>Thu, 14 Aug 2008 21:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-383</guid>
		<description>thanks this small but focused toturial helped me understand a few things.</description>
		<content:encoded><![CDATA[<p>thanks this small but focused toturial helped me understand a few things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josip</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-382</link>
		<dc:creator>josip</dc:creator>
		<pubDate>Thu, 14 Aug 2008 18:08:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-382</guid>
		<description>You could shrink it even more :)

$(&quot;ul#langs&quot;).click(function (event) {
  var id = $(event.originalTarget).text().toLowerCase();
  $(&quot;#container div&quot;)
    .hide()
    .filter(&quot;#&quot; + id)
      .fadeIn(&quot;slow&quot;);
});

(note that you were using same ID twice, for list item and div)</description>
		<content:encoded><![CDATA[<p>You could shrink it even more <img src='http://query7.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>$(&#8220;ul#langs&#8221;).click(function (event) {<br />
  var id = $(event.originalTarget).text().toLowerCase();<br />
  $(&#8220;#container div&#8221;)<br />
    .hide()<br />
    .filter(&#8220;#&#8221; + id)<br />
      .fadeIn(&#8220;slow&#8221;);<br />
});</p>
<p>(note that you were using same ID twice, for list item and div)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karol Kowalski</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-381</link>
		<dc:creator>Karol Kowalski</dc:creator>
		<pubDate>Thu, 14 Aug 2008 17:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-381</guid>
		<description>You can&#039;t have multiple elements with the same id. If your code works it&#039;s only because of browsers quirks. Also querying $(&#039;element#id&#039;) is slower than actually querying $(&#039;#id&#039;), because the browser needs to parse the DOM searching for all nodes of certain name and only later it can traverse them searching for the #id.</description>
		<content:encoded><![CDATA[<p>You can&#8217;t have multiple elements with the same id. If your code works it&#8217;s only because of browsers quirks. Also querying $(&#8216;element#id&#8217;) is slower than actually querying $(&#8216;#id&#8217;), because the browser needs to parse the DOM searching for all nodes of certain name and only later it can traverse them searching for the #id.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vish</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-380</link>
		<dc:creator>vish</dc:creator>
		<pubDate>Thu, 14 Aug 2008 14:52:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-380</guid>
		<description>This is vary nice  good lookup site.</description>
		<content:encoded><![CDATA[<p>This is vary nice  good lookup site.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Migliorisi</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-378</link>
		<dc:creator>Bryan Migliorisi</dc:creator>
		<pubDate>Thu, 14 Aug 2008 14:05:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-378</guid>
		<description>I am pretty sure that both of your methods will be creating individual event listeners for each element found in the selection.

Instead, you should only attach an event listener on the ul only and then on the click event, find out which inner target element was clicked.  That is how you would lower the amount of event listeners.

Also, you cant have mutliple elements on a single page share the same ID.  This is invalid XHTML</description>
		<content:encoded><![CDATA[<p>I am pretty sure that both of your methods will be creating individual event listeners for each element found in the selection.</p>
<p>Instead, you should only attach an event listener on the ul only and then on the click event, find out which inner target element was clicked.  That is how you would lower the amount of event listeners.</p>
<p>Also, you cant have mutliple elements on a single page share the same ID.  This is invalid XHTML</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-377</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 14 Aug 2008 13:56:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-377</guid>
		<description>You may want to keep in mind that you should only be using an id once per page.  If you were to use something like document.getElementById(&quot;php&quot;) it would only return the first one.

You could change $(&quot;div#container div#&quot; + elid + &quot;&quot;).fadeIn(&quot;slow&quot;); to $(&quot;div#container div#&quot; + elid + &quot;content&quot;).fadeIn(&quot;slow&quot;); and append &quot;content&quot; to all of the div ids.</description>
		<content:encoded><![CDATA[<p>You may want to keep in mind that you should only be using an id once per page.  If you were to use something like document.getElementById(&#8220;php&#8221;) it would only return the first one.</p>
<p>You could change $(&#8220;div#container div#&#8221; + elid + &#8220;&#8221;).fadeIn(&#8220;slow&#8221;); to $(&#8220;div#container div#&#8221; + elid + &#8220;content&#8221;).fadeIn(&#8220;slow&#8221;); and append &#8220;content&#8221; to all of the div ids.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Grossberg</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-374</link>
		<dc:creator>Joe Grossberg</dc:creator>
		<pubDate>Thu, 14 Aug 2008 13:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-374</guid>
		<description>Why do you have

$(&quot;div#container div#&quot; + elid + &quot;&quot;)

instead of just

$(&quot;div#container div#&quot; + elid)

?</description>
		<content:encoded><![CDATA[<p>Why do you have</p>
<p>$(&#8220;div#container div#&#8221; + elid + &#8220;&#8221;)</p>
<p>instead of just</p>
<p>$(&#8220;div#container div#&#8221; + elid)</p>
<p>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Effectize</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-371</link>
		<dc:creator>Effectize</dc:creator>
		<pubDate>Thu, 14 Aug 2008 07:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-371</guid>
		<description>&lt;strong&gt;The Complete Guide for You to Become an Almighty jQuery Developer...&lt;/strong&gt;

Have you ever had to develop something yourself only to find out that there had already been a plugin developed?


Don&#039;t you enjoy dreaming about what you could have on your site and finding the right plugin right away?


Then you should find this lis...</description>
		<content:encoded><![CDATA[<p><strong>The Complete Guide for You to Become an Almighty jQuery Developer&#8230;</strong></p>
<p>Have you ever had to develop something yourself only to find out that there had already been a plugin developed?</p>
<p>Don&#8217;t you enjoy dreaming about what you could have on your site and finding the right plugin right away?</p>
<p>Then you should find this lis&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yura</title>
		<link>http://query7.com/writing-better-jquery-code/comment-page-1#comment-372</link>
		<dc:creator>Yura</dc:creator>
		<pubDate>Thu, 14 Aug 2008 07:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.query7.com/?p=98#comment-372</guid>
		<description>Hi there.

That&#039;s some great article. Of all the &lt;a href=&quot;http://effectize.com/jquery-developer-guide&quot; rel=&quot;nofollow&quot;&gt;jQuery resources that I have collected&lt;/a&gt;, it is the only one that actually talks about writing better code.

Thanks.</description>
		<content:encoded><![CDATA[<p>Hi there.</p>
<p>That&#8217;s some great article. Of all the <a href="http://effectize.com/jquery-developer-guide" rel="nofollow">jQuery resources that I have collected</a>, it is the only one that actually talks about writing better code.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
Loading ...