<?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 on: Breaking The&#160;Rules</title>
	<atom:link href="http://particletree.com/notebook/breaking-the-rules/feed/" rel="self" type="application/rss+xml" />
	<link>http://particletree.com/notebook/breaking-the-rules/</link>
	<description>Everyone needs a hug.</description>
	<pubDate>Fri, 25 Jul 2008 12:42:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Leptos Estates</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20818</link>
		<dc:creator>Leptos Estates</dc:creator>
		<pubDate>Thu, 17 May 2007 06:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20818</guid>
		<description>&lt;p&gt;Property in Greece. Wide range of holiday and residential properties from the leading property developer. Excellent investment opportunities. Custom built and completed properties in Greece, Paros, Crete and Santorini.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Property in Greece. Wide range of holiday and residential properties from the leading property developer. Excellent investment opportunities. Custom built and completed properties in Greece, Paros, Crete and Santorini.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Keogh</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20644</link>
		<dc:creator>Matt Keogh</dc:creator>
		<pubDate>Mon, 30 Apr 2007 13:09:55 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20644</guid>
		<description>&lt;p&gt;I think the hover technique described by Dave Kees in the comments makes more sense.You can set the hover behaviour using conditional comments just for the IE 5 and 6. That way we keep the code clean and you only have to set it once. Obviously you have to remember to think about what happens when JS if off still.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I think the hover technique described by Dave Kees in the comments makes more sense.You can set the hover behaviour using conditional comments just for the IE 5 and 6. That way we keep the code clean and you only have to set it once. Obviously you have to remember to think about what happens when JS if off still.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Dustin Diaz</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20597</link>
		<dc:creator>Dustin Diaz</dc:creator>
		<pubDate>Tue, 24 Apr 2007 06:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20597</guid>
		<description>&lt;p&gt;I just want to say that I agree with everything that was said in this article. I know I haven't been a while for ages, but it was a breath of fresh air seeing other js ninja's breaking the rules as well. It's just downright practical.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I just want to say that I agree with everything that was said in this article. I know I haven&#8217;t been a while for ages, but it was a breath of fresh air seeing other js ninja&#8217;s breaking the rules as well. It&#8217;s just downright practical.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: awflasher</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20592</link>
		<dc:creator>awflasher</dc:creator>
		<pubDate>Mon, 23 Apr 2007 09:56:18 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20592</guid>
		<description>&lt;p&gt;Hey, I find this topic by accident, sounds great.
BTW, I am a web developer from China.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hey, I find this topic by accident, sounds great.
BTW, I am a web developer from China.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Binny V A</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20544</link>
		<dc:creator>Binny V A</dc:creator>
		<pubDate>Wed, 11 Apr 2007 10:38:32 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20544</guid>
		<description>&lt;p&gt;As long as you know what you are doing, I guess breaking rules are OK.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>As long as you know what you are doing, I guess breaking rules are OK.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Graham</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20541</link>
		<dc:creator>Graham</dc:creator>
		<pubDate>Tue, 10 Apr 2007 15:36:11 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20541</guid>
		<description>&lt;p&gt;Not to split hairs, but if you have 50 LIs and only the most recently clicked one gets the class "selected" then you should really us an ID instead of a class. This way, in order to remove the old "selected" and apply it to a new class, you can just do something like $('selected').setAttribute("id","") when the new LI is clicked, then add that ID back to the newly clicked LI.&lt;/p&gt;

&lt;p&gt;function changeSelected(argumentElement) {
   $('selected').setAttribute("id","");
   argumentElement.setAttribute("id","selected");
}
// fire this function when any LI is clicked and pass the clicked LI as the argument.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Not to split hairs, but if you have 50 LIs and only the most recently clicked one gets the class &#8220;selected&#8221; then you should really us an ID instead of a class. This way, in order to remove the old &#8220;selected&#8221; and apply it to a new class, you can just do something like $(&#8216;selected&#8217;).setAttribute(&#8220;id&#8221;,&#8221;&#8220;) when the new LI is clicked, then add that ID back to the newly clicked LI.</p>

<p>function changeSelected(argumentElement) {
   $(&#8216;selected&#8217;).setAttribute(&#8220;id&#8221;,&#8221;&#8220;);
   argumentElement.setAttribute(&#8220;id&#8221;,&#8221;selected&#8221;);
}
// fire this function when any LI is clicked and pass the clicked LI as the argument.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tobie Langel</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20539</link>
		<dc:creator>Tobie Langel</dc:creator>
		<pubDate>Mon, 09 Apr 2007 22:19:59 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20539</guid>
		<description>&lt;p&gt;Actually, as you are setting one observer instead of 50, you should get pretty drastic performance improvements.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Actually, as you are setting one observer instead of 50, you should get pretty drastic performance improvements.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Campbell</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20538</link>
		<dc:creator>Ryan Campbell</dc:creator>
		<pubDate>Mon, 09 Apr 2007 21:43:51 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20538</guid>
		<description>&lt;p&gt;Yeah, Tobie, the more I look at your approach the more I like it. On the surface it appears more complex, but it is reusable and self sustaining, which is nice. The reason I initially switched to globals is because of performance. If Event.findElement has no performance drawbacks, then I think I'll start trying this approach.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yeah, Tobie, the more I look at your approach the more I like it. On the surface it appears more complex, but it is reusable and self sustaining, which is nice. The reason I initially switched to globals is because of performance. If Event.findElement has no performance drawbacks, then I think I&#8217;ll start trying this approach.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Irish</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20537</link>
		<dc:creator>Paul Irish</dc:creator>
		<pubDate>Mon, 09 Apr 2007 21:15:02 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20537</guid>
		<description>&lt;p&gt;I so appreciate it when others make use of the onclick attribute, it makes analyzing someone else's code FAR easier. I don't see a good justification for why event attaching needs to be done more unobtrusively.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I so appreciate it when others make use of the onclick attribute, it makes analyzing someone else&#8217;s code FAR easier. I don&#8217;t see a good justification for why event attaching needs to be done more unobtrusively.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tobie Langel</title>
		<link>http://particletree.com/notebook/breaking-the-rules/#comment-20536</link>
		<dc:creator>Tobie Langel</dc:creator>
		<pubDate>Mon, 09 Apr 2007 21:11:10 +0000</pubDate>
		<guid isPermaLink="false">http://particletree.com/notebook/breaking-the-rules/#comment-20536</guid>
		<description>&lt;p&gt;Actually, let me rephrase that:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var Selector = Class.create();
Selector.prototype = {
  initialize: function(list) {
    list = $(list);
    this.onClick = this.select.bindAsEventListener(this);
    list.observe('click', this.onClick);
    this.selected = list.getElementsByClassName("selected").first() &#124;&#124; null;
  },

  select: function(event) {
    var element = $(Event.findElement(event, 'li'));
    if(!element.hasClassName("selected")) {
      if(this.selected)
        this.selected.removeClassName("selected");
      element.addClassName("selected");
      this.selected = element;
    }
  }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Better ?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Actually, let me rephrase that:</p>

<pre><code>var Selector = Class.create();
Selector.prototype = {
  initialize: function(list) {
    list = $(list);
    this.onClick = this.select.bindAsEventListener(this);
    list.observe('click', this.onClick);
    this.selected = list.getElementsByClassName("selected").first() || null;
  },

  select: function(event) {
    var element = $(Event.findElement(event, 'li'));
    if(!element.hasClassName("selected")) {
      if(this.selected)
        this.selected.removeClassName("selected");
      element.addClassName("selected");
      this.selected = element;
    }
  }
}</code></pre>

<p>Better&#160;?</p>]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.218 seconds -->
