<?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: &#8216;Events&#8217; interface for jQuery</title>
	<atom:link href="http://james.padolsey.com/javascript/events-interface-for-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://james.padolsey.com/javascript/events-interface-for-jquery/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 29 Aug 2010 12:37:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mahbub</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-11437</link>
		<dc:creator>Mahbub</dc:creator>
		<pubDate>Sat, 09 May 2009 04:51:08 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-11437</guid>
		<description>Nice Idea. I too sometimes felt that there should be a separate scope for event related routines in jQuery. I think i&#039;ll use it next. 
Nice work James, keep changing the world!!</description>
		<content:encoded><![CDATA[<p>Nice Idea. I too sometimes felt that there should be a separate scope for event related routines in jQuery. I think i&#8217;ll use it next.<br />
Nice work James, keep changing the world!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hal Helms</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-9183</link>
		<dc:creator>Hal Helms</dc:creator>
		<pubDate>Sun, 05 Apr 2009 03:13:33 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-9183</guid>
		<description>Nice work, James. Thanks.</description>
		<content:encoded><![CDATA[<p>Nice work, James. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8924</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 01 Apr 2009 20:32:55 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8924</guid>
		<description>I like the tip you came up with here and I&#039;ve found your blog to be a great read.

ExtJs uses a similar way to what you&#039;ve suggested to add multiple event handlers.

&lt;pre lang=&quot;javascript&quot;&gt;
var el = Ext.get(&quot;my-dom-el&quot;);

el.on({
    &#039;click&#039; : {
        fn: this.onClick,
        scope: this,
        delay: 100
    },
    &#039;mouseover&#039; : {
        fn: this.onMouseOver,
        scope: this
    },
    &#039;mouseout&#039; : {
        fn: this.onMouseOut,
        scope: this
    }
});

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I like the tip you came up with here and I&#8217;ve found your blog to be a great read.</p>
<p>ExtJs uses a similar way to what you&#8217;ve suggested to add multiple event handlers.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw2">var</span> el <span class="sy0">=</span> Ext.<span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;my-dom-el&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
el.<span class="me1">on</span><span class="br0">&#40;</span><span class="br0">&#123;</span>
    <span class="st0">'click'</span> <span class="sy0">:</span> <span class="br0">&#123;</span>
        fn<span class="sy0">:</span> <span class="kw1">this</span>.<span class="me1">onClick</span><span class="sy0">,</span>
        scope<span class="sy0">:</span> <span class="kw1">this</span><span class="sy0">,</span>
        delay<span class="sy0">:</span> <span class="nu0">100</span>
    <span class="br0">&#125;</span><span class="sy0">,</span>
    <span class="st0">'mouseover'</span> <span class="sy0">:</span> <span class="br0">&#123;</span>
        fn<span class="sy0">:</span> <span class="kw1">this</span>.<span class="me1">onMouseOver</span><span class="sy0">,</span>
        scope<span class="sy0">:</span> <span class="kw1">this</span>
    <span class="br0">&#125;</span><span class="sy0">,</span>
    <span class="st0">'mouseout'</span> <span class="sy0">:</span> <span class="br0">&#123;</span>
        fn<span class="sy0">:</span> <span class="kw1">this</span>.<span class="me1">onMouseOut</span><span class="sy0">,</span>
        scope<span class="sy0">:</span> <span class="kw1">this</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8918</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Wed, 01 Apr 2009 18:04:13 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8918</guid>
		<description>You can go to this nice extreme too, because we know that jQuery loves overloading methods :-)

&lt;pre lang=&quot;javascript&quot;&gt;
jQuery.fn._bind = jQuery.fn.bind;
jQuery.fn.bind = function(events) {
  if (typeof events == &#039;string&#039;)
    return this._bind.apply(this, arguments);
  for (var type in events)
    this._bind(type, events[type]);
  return this;
};
&lt;/pre&gt;

This will let you use the &lt;code&gt;bind()&lt;/code&gt; method as you wanted while also still being able to use it the original way.</description>
		<content:encoded><![CDATA[<p>You can go to this nice extreme too, because we know that jQuery loves overloading methods <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span class="me1">fn</span>._bind <span class="sy0">=</span> jQuery.<span class="me1">fn</span>.<span class="me1">bind</span><span class="sy0">;</span>
jQuery.<span class="me1">fn</span>.<span class="me1">bind</span> <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span>events<span class="br0">&#41;</span> <span class="br0">&#123;</span>
  <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> events <span class="sy0">==</span> <span class="st0">'string'</span><span class="br0">&#41;</span>
    <span class="kw1">return</span> <span class="kw1">this</span>._bind.<span class="me1">apply</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="sy0">,</span> arguments<span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> type <span class="kw1">in</span> events<span class="br0">&#41;</span>
    <span class="kw1">this</span>._bind<span class="br0">&#40;</span>type<span class="sy0">,</span> events<span class="br0">&#91;</span>type<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
  <span class="kw1">return</span> <span class="kw1">this</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span></pre></div></div>

<p>This will let you use the <code>bind()</code> method as you wanted while also still being able to use it the original way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8912</link>
		<dc:creator>Ivan</dc:creator>
		<pubDate>Wed, 01 Apr 2009 14:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8912</guid>
		<description>it&#039;s a cute approach.  i wouldn&#039;t say is a huge win over the standard way of doing it.  i bet you add your events enough times and you&#039;ll go back to doing it the old way.</description>
		<content:encoded><![CDATA[<p>it&#8217;s a cute approach.  i wouldn&#8217;t say is a huge win over the standard way of doing it.  i bet you add your events enough times and you&#8217;ll go back to doing it the old way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8887</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 01 Apr 2009 03:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8887</guid>
		<description>Nice to find someone else dislikes this ugly code that jQuery -unintentionally- making people get used to.</description>
		<content:encoded><![CDATA[<p>Nice to find someone else dislikes this ugly code that jQuery -unintentionally- making people get used to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julio Cesar Ody</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8881</link>
		<dc:creator>Julio Cesar Ody</dc:creator>
		<pubDate>Tue, 31 Mar 2009 22:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8881</guid>
		<description>Yeah, all form of abuse considered harmful  :)  though it strikes me that in this case, it&#039;s simply an escape to the element&#039;s scope in order to declare a few jQuery events. Which makes it not so bad IMO.

Thanks for the link though.</description>
		<content:encoded><![CDATA[<p>Yeah, all form of abuse considered harmful  <img src='http://james.padolsey.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   though it strikes me that in this case, it&#8217;s simply an escape to the element&#8217;s scope in order to declare a few jQuery events. Which makes it not so bad IMO.</p>
<p>Thanks for the link though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8879</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 31 Mar 2009 22:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8879</guid>
		<description>@Rick, while I agree I don&#039;t see this as a barrier that can&#039;t be overcome by continuing with jQuery. I&#039;ve tried MooTools but I don&#039;t like it since it extends native DOM properties and the prototypes of native datatypes - something which is generally not a good idea.

@Dan, exactly. The problem with jQuery&#039;s chaining is that it looks awful if you don&#039;t indent, and when you &lt;em&gt;do&lt;/em&gt; indent it can create confusion and, as you said, invalidation...

@Julio, Nice solution, thanks. Although, note that it&#039;s generally &lt;a href=&quot;http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/&quot; rel=&quot;nofollow&quot;&gt;not a good idea to use the &lt;code&gt;with&lt;/code&gt; statement&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Rick, while I agree I don&#8217;t see this as a barrier that can&#8217;t be overcome by continuing with jQuery. I&#8217;ve tried MooTools but I don&#8217;t like it since it extends native DOM properties and the prototypes of native datatypes &#8211; something which is generally not a good idea.</p>
<p>@Dan, exactly. The problem with jQuery&#8217;s chaining is that it looks awful if you don&#8217;t indent, and when you <em>do</em> indent it can create confusion and, as you said, invalidation&#8230;</p>
<p>@Julio, Nice solution, thanks. Although, note that it&#8217;s generally <a href="http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/">not a good idea to use the <code>with</code> statement</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julio Cesar Ody</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8878</link>
		<dc:creator>Julio Cesar Ody</dc:creator>
		<pubDate>Tue, 31 Mar 2009 22:12:34 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8878</guid>
		<description>&lt;pre lang=&quot;javascript&quot;&gt;
with( $(elem) ) {

  click( function() { ... } );
  hover( function() { ... } );
}
&lt;/pre&gt;

And so on, and so forth.</description>
		<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="kw1">with</span><span class="br0">&#40;</span> $<span class="br0">&#40;</span>elem<span class="br0">&#41;</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
  click<span class="br0">&#40;</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> ... <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
  hover<span class="br0">&#40;</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> ... <span class="br0">&#125;</span> <span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>

<p>And so on, and so forth.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://james.padolsey.com/javascript/events-interface-for-jquery/comment-page-1/#comment-8875</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 31 Mar 2009 20:23:28 +0000</pubDate>
		<guid isPermaLink="false">http://james.padolsey.com/?p=722#comment-8875</guid>
		<description>Neat idea. Will also stop JSlint complaining that its &#039;ambiguous whether these lines are part of the same statement&#039;, which it would do in the first example.</description>
		<content:encoded><![CDATA[<p>Neat idea. Will also stop JSlint complaining that its &#8216;ambiguous whether these lines are part of the same statement&#8217;, which it would do in the first example.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
