<?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: Event.Behavior: DSL for JavaScript</title>
	<atom:link href="http://ajaxian.com/archives/eventbehavior-dsl-for-javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/eventbehavior-dsl-for-javascript</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: Colin</title>
		<link>http://ajaxian.com/archives/eventbehavior-dsl-for-javascript/comment-page-1#comment-249079</link>
		<dc:creator>Colin</dc:creator>
		<pubDate>Fri, 06 Apr 2007 09:42:07 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2289#comment-249079</guid>
		<description>Interesting idea, but please don&#039;t sacrifice code quality for dumbed down readability, that&#039;s what comments are for. One of the examples on that page is:
with(Event.Behavior){
add_class_name(&#039;black&#039;).to(&#039;paragraph&#039;).when(&#039;color_select&#039;).is(&#039;black&#039;);
add_class_name(&#039;red&#039;).to(&#039;paragraph&#039;).when(&#039;color_select&#039;).is(&#039;red&#039;);
add_class_name(&#039;green&#039;).to(&#039;paragraph&#039;).when(&#039;color_select&#039;).is(&#039;green&#039;);
add_class_name(&#039;blue&#039;).to(&#039;paragraph&#039;).when(&#039;color_select&#039;).is(&#039;blue&#039;);
add_class_name(&#039;bold&#039;).to(&#039;paragraph&#039;).when(&#039;weight_select&#039;).is(&#039;bold&#039;);
add_class_name(&#039;normal&#039;).to(&#039;paragraph&#039;).when(&#039;weight_select&#039;).is(&#039;normal&#039;);
}

This should be simply: 
$(&#039;color_select&#039;,&#039;weight_select&#039;).invoke(&#039;observe&#039;,&#039;change&#039;,function(event){
  $(&#039;paragraph&#039;).addClassName(Event.element(event).value);
});

I could be wrong but I&#039;m guessing each Event.Behavior &quot;statement&quot; is a separate event observer, so not only is this example extremely verbose, but it&#039;s also very inefficient and not maintainable. However, some other examples they used were actually pretty cool.

Suggestion: for all constructs that can take a function which returns an array of elements, you could make the code much cleaner by allowing you to pass a string which is assumed to be a CSS selector, in which case it would pass that to $$ itself rather than requiring you to pass it a function that just wraps $$. This would also be more readable since you don&#039;t have ugly inline functions or functions defined elsewhere.
Example:
with(Event.Behavior){
set_style(styles).on(&#039;#font_picker p&#039;).when(&#039;#font_picker select&#039;).change();
}</description>
		<content:encoded><![CDATA[<p>Interesting idea, but please don&#8217;t sacrifice code quality for dumbed down readability, that&#8217;s what comments are for. One of the examples on that page is:<br />
with(Event.Behavior){<br />
add_class_name(&#8216;black&#8217;).to(&#8216;paragraph&#8217;).when(&#8216;color_select&#8217;).is(&#8216;black&#8217;);<br />
add_class_name(&#8216;red&#8217;).to(&#8216;paragraph&#8217;).when(&#8216;color_select&#8217;).is(&#8216;red&#8217;);<br />
add_class_name(&#8216;green&#8217;).to(&#8216;paragraph&#8217;).when(&#8216;color_select&#8217;).is(&#8216;green&#8217;);<br />
add_class_name(&#8216;blue&#8217;).to(&#8216;paragraph&#8217;).when(&#8216;color_select&#8217;).is(&#8216;blue&#8217;);<br />
add_class_name(&#8216;bold&#8217;).to(&#8216;paragraph&#8217;).when(&#8216;weight_select&#8217;).is(&#8216;bold&#8217;);<br />
add_class_name(&#8216;normal&#8217;).to(&#8216;paragraph&#8217;).when(&#8216;weight_select&#8217;).is(&#8216;normal&#8217;);<br />
}</p>
<p>This should be simply:<br />
$(&#8216;color_select&#8217;,'weight_select&#8217;).invoke(&#8216;observe&#8217;,'change&#8217;,function(event){<br />
  $(&#8216;paragraph&#8217;).addClassName(Event.element(event).value);<br />
});</p>
<p>I could be wrong but I&#8217;m guessing each Event.Behavior &#8220;statement&#8221; is a separate event observer, so not only is this example extremely verbose, but it&#8217;s also very inefficient and not maintainable. However, some other examples they used were actually pretty cool.</p>
<p>Suggestion: for all constructs that can take a function which returns an array of elements, you could make the code much cleaner by allowing you to pass a string which is assumed to be a CSS selector, in which case it would pass that to $$ itself rather than requiring you to pass it a function that just wraps $$. This would also be more readable since you don&#8217;t have ugly inline functions or functions defined elsewhere.<br />
Example:<br />
with(Event.Behavior){<br />
set_style(styles).on(&#8216;#font_picker p&#8217;).when(&#8216;#font_picker select&#8217;).change();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andy</title>
		<link>http://ajaxian.com/archives/eventbehavior-dsl-for-javascript/comment-page-1#comment-249063</link>
		<dc:creator>andy</dc:creator>
		<pubDate>Thu, 05 Apr 2007 21:16:06 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2289#comment-249063</guid>
		<description>i thought pseudocode meant code that shows an idea but doesn&#039;t actually run</description>
		<content:encoded><![CDATA[<p>i thought pseudocode meant code that shows an idea but doesn&#8217;t actually run</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steve</title>
		<link>http://ajaxian.com/archives/eventbehavior-dsl-for-javascript/comment-page-1#comment-249061</link>
		<dc:creator>steve</dc:creator>
		<pubDate>Thu, 05 Apr 2007 21:04:59 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2289#comment-249061</guid>
		<description>um..... can anyone say &quot;big deal&quot; and/or  why is pseudocode being heralded as an invention??</description>
		<content:encoded><![CDATA[<p>um&#8230;.. can anyone say &#8220;big deal&#8221; and/or  why is pseudocode being heralded as an invention??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres Almiray</title>
		<link>http://ajaxian.com/archives/eventbehavior-dsl-for-javascript/comment-page-1#comment-249055</link>
		<dc:creator>Andres Almiray</dc:creator>
		<pubDate>Thu, 05 Apr 2007 19:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2289#comment-249055</guid>
		<description>Very interesting indeed. I bet Adam didn&#039;t see this one coming. Congrats to Ryan on putting a good idea to work.</description>
		<content:encoded><![CDATA[<p>Very interesting indeed. I bet Adam didn&#8217;t see this one coming. Congrats to Ryan on putting a good idea to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicolas</title>
		<link>http://ajaxian.com/archives/eventbehavior-dsl-for-javascript/comment-page-1#comment-249043</link>
		<dc:creator>Nicolas</dc:creator>
		<pubDate>Thu, 05 Apr 2007 14:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=2289#comment-249043</guid>
		<description>Wow very insteresting project ... bonus, It will help me to improve my english ;)</description>
		<content:encoded><![CDATA[<p>Wow very insteresting project &#8230; bonus, It will help me to improve my english ;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

