<?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: jQuery Bondage</title>
	<atom:link href="http://ajaxian.com/archives/jquery-bondage/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/jquery-bondage</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: yashraj2</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-284316</link>
		<dc:creator>yashraj2</dc:creator>
		<pubDate>Wed, 23 Jun 2010 09:42:26 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-284316</guid>
		<description>Hey,

It’s a nice tutorial to understand jquery.

I have found another great tutorial site with almost all the information of jquery in php.

http://phpschools.freehostia.com</description>
		<content:encoded><![CDATA[<p>Hey,</p>
<p>It’s a nice tutorial to understand jquery.</p>
<p>I have found another great tutorial site with almost all the information of jquery in php.</p>
<p><a href="http://phpschools.freehostia.com" rel="nofollow">http://phpschools.freehostia.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JustinMeyer</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276455</link>
		<dc:creator>JustinMeyer</dc:creator>
		<pubDate>Tue, 10 Nov 2009 06:01:29 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276455</guid>
		<description>@furf, I&#039;ve been trying to convince jQuery that live should be something like:

$(&#039;table&#039;).delegate(&#039;tr&#039;,&#039;click&#039;,func);

Btw, JavaScriptMVC&#039;s delegator plugin provides this for all common events (submit) much faster than jQuery.</description>
		<content:encoded><![CDATA[<p>@furf, I&#8217;ve been trying to convince jQuery that live should be something like:</p>
<p>$(&#8216;table&#8217;).delegate(&#8216;tr&#8217;,'click&#8217;,func);</p>
<p>Btw, JavaScriptMVC&#8217;s delegator plugin provides this for all common events (submit) much faster than jQuery.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: furf</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276341</link>
		<dc:creator>furf</dc:creator>
		<pubDate>Thu, 05 Nov 2009 17:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276341</guid>
		<description>I was among the others with a quick patch for .live (http://blurf.furf.com/2009/09/jquery-live-from-new-york/), inspired by Paul&#039;s preso at jqcon in Boston. But on my flight to Berlin for jsconf, I decided the best way to get it into the framework for reals was to patch it for reals and put .live() where it belongs. So here&#039;s my external patch, which can become a real patch with two copies and two pastes: http://github.com/furf/jquery-live/blob/master/jquery.live.js</description>
		<content:encoded><![CDATA[<p>I was among the others with a quick patch for .live (<a href="http://blurf.furf.com/2009/09/jquery-live-from-new-york/" rel="nofollow">http://blurf.furf.com/2009/09/jquery-live-from-new-york/</a>), inspired by Paul&#8217;s preso at jqcon in Boston. But on my flight to Berlin for jsconf, I decided the best way to get it into the framework for reals was to patch it for reals and put .live() where it belongs. So here&#8217;s my external patch, which can become a real patch with two copies and two pastes: <a href="http://github.com/furf/jquery-live/blob/master/jquery.live.js" rel="nofollow">http://github.com/furf/jquery-live/blob/master/jquery.live.js</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sebr</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276326</link>
		<dc:creator>sebr</dc:creator>
		<pubDate>Wed, 04 Nov 2009 23:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276326</guid>
		<description>Hey folks,
Here&#039;s the link to my original article:
http://blogs.atlassian.com/developer/2009/08/jquery_bondage.html

At the end of the day, we chose to use jQuery&#039;s live because:
1. it was easy to use, and fit in well with our existing jQuery infrastructure
2. we didn&#039;t see the need to &quot;roll our own&quot; because at the end of the day, using live worked well enough for our usages</description>
		<content:encoded><![CDATA[<p>Hey folks,<br />
Here&#8217;s the link to my original article:<br />
<a href="http://blogs.atlassian.com/developer/2009/08/jquery_bondage.html" rel="nofollow">http://blogs.atlassian.com/developer/2009/08/jquery_bondage.html</a></p>
<p>At the end of the day, we chose to use jQuery&#8217;s live because:<br />
1. it was easy to use, and fit in well with our existing jQuery infrastructure<br />
2. we didn&#8217;t see the need to &#8220;roll our own&#8221; because at the end of the day, using live worked well enough for our usages</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jlizarraga</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276323</link>
		<dc:creator>jlizarraga</dc:creator>
		<pubDate>Wed, 04 Nov 2009 22:22:37 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276323</guid>
		<description>I was a little confused at first about the nature of this article. I had the same &quot;ajaxian, where&#039;s the event delegation&quot; reaction that everyone else had. But I did learn something from this post, namely the added unload time created by event garbage collection. Never would have thought to measure that.</description>
		<content:encoded><![CDATA[<p>I was a little confused at first about the nature of this article. I had the same &#8220;ajaxian, where&#8217;s the event delegation&#8221; reaction that everyone else had. But I did learn something from this post, namely the added unload time created by event garbage collection. Never would have thought to measure that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jadet</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276319</link>
		<dc:creator>Jadet</dc:creator>
		<pubDate>Wed, 04 Nov 2009 22:11:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276319</guid>
		<description>Nice work there Diego. You mentioned not having a framework, why not write your own and use NWMatcher in there? Who knows, maybe some frameworks will pick up on a thing or two ;)</description>
		<content:encoded><![CDATA[<p>Nice work there Diego. You mentioned not having a framework, why not write your own and use NWMatcher in there? Who knows, maybe some frameworks will pick up on a thing or two ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dperini</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276316</link>
		<dc:creator>dperini</dc:creator>
		<pubDate>Wed, 04 Nov 2009 21:23:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276316</guid>
		<description>@sixtyseconds
int the code you have the choice to not use the &quot;documentElement&quot; if that doesn&#039;t fit your requirements, but then you will need to wait &quot;onload/ready&quot;, at that time you can add a last argument to the above example which will be the &quot;parent&quot; node you would like to listen on, to shorten the bubbling path.

As a bonus, form events like submit/focus/change can be used with delegation as any other element event and cross-frames events.

Capturing of events is available also for IE, with those I am trying to cover Aria/A11Y compliance.</description>
		<content:encoded><![CDATA[<p>@sixtyseconds<br />
int the code you have the choice to not use the &#8220;documentElement&#8221; if that doesn&#8217;t fit your requirements, but then you will need to wait &#8220;onload/ready&#8221;, at that time you can add a last argument to the above example which will be the &#8220;parent&#8221; node you would like to listen on, to shorten the bubbling path.</p>
<p>As a bonus, form events like submit/focus/change can be used with delegation as any other element event and cross-frames events.</p>
<p>Capturing of events is available also for IE, with those I am trying to cover Aria/A11Y compliance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sixtyseconds</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276315</link>
		<dc:creator>sixtyseconds</dc:creator>
		<pubDate>Wed, 04 Nov 2009 21:09:19 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276315</guid>
		<description>@dperini - Yes - jdalton explained it to me :D
Do you think it&#039;s the most efficient way to handle things considering you would essentially wait for ALL events to bubble up to documentElement? Surely very few, if any, need to bubble that far...I think I wondered though - the issue in this article was more about delegation than it was about domready vs. NWMatcher. Good work though.</description>
		<content:encoded><![CDATA[<p>@dperini &#8211; Yes &#8211; jdalton explained it to me :D<br />
Do you think it&#8217;s the most efficient way to handle things considering you would essentially wait for ALL events to bubble up to documentElement? Surely very few, if any, need to bubble that far&#8230;I think I wondered though &#8211; the issue in this article was more about delegation than it was about domready vs. NWMatcher. Good work though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dperini</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276314</link>
		<dc:creator>dperini</dc:creator>
		<pubDate>Wed, 04 Nov 2009 21:01:25 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276314</guid>
		<description>@sixtyseconds,
Yes ... I can honestly say that NWEvents works like that, even if it is hard to believe it:

NW.Event.appendDelegate(&#039;ul#nav li:nth-child(even)&#039;, &#039;mouseover&#039;, fn);

and you can execute that as the very first line of your script without the need to wait for &quot;onload&quot; or &quot;ready&quot; events. The code to load to make this work is about 3Kb.

So it is not just the delegation problem you get solved but a lot of other nasty &quot;non cross-browser&quot; behaviors like &quot;onload/ready&quot; events.</description>
		<content:encoded><![CDATA[<p>@sixtyseconds,<br />
Yes &#8230; I can honestly say that NWEvents works like that, even if it is hard to believe it:</p>
<p>NW.Event.appendDelegate(&#8216;ul#nav li:nth-child(even)&#8217;, &#8216;mouseover&#8217;, fn);</p>
<p>and you can execute that as the very first line of your script without the need to wait for &#8220;onload&#8221; or &#8220;ready&#8221; events. The code to load to make this work is about 3Kb.</p>
<p>So it is not just the delegation problem you get solved but a lot of other nasty &#8220;non cross-browser&#8221; behaviors like &#8220;onload/ready&#8221; events.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sixtyseconds</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276313</link>
		<dc:creator>sixtyseconds</dc:creator>
		<pubDate>Wed, 04 Nov 2009 20:56:07 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276313</guid>
		<description>@jdalton - How right you are! We learn new things every day :D</description>
		<content:encoded><![CDATA[<p>@jdalton &#8211; How right you are! We learn new things every day :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jdalton</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276312</link>
		<dc:creator>jdalton</dc:creator>
		<pubDate>Wed, 04 Nov 2009 20:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276312</guid>
		<description>@sixtyseconds - The document.documentElement is there ;D</description>
		<content:encoded><![CDATA[<p>@sixtyseconds &#8211; The document.documentElement is there ;D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paulbo99</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276311</link>
		<dc:creator>paulbo99</dc:creator>
		<pubDate>Wed, 04 Nov 2009 20:16:06 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276311</guid>
		<description>In my experience the best performing solution is to put onclick=&quot;...&quot; in the tr tag html. This performs significantly better with 100s of elements - you don&#039;t even need 1000s (although maybe the difference isn&#039;t as significant if you use chrome, or a fast computer). If you generate the page, why would you plan on making the browser do a significant amount of post-processing after the page is loaded/rendered?
Sure, a simple css selector and bind is elegant, but it&#039;s hard to expect 10k dom manipulations to perform well. Just make the page the way you like it in the first place and bind stuff dynamically only as needed.</description>
		<content:encoded><![CDATA[<p>In my experience the best performing solution is to put onclick=&#8221;&#8230;&#8221; in the tr tag html. This performs significantly better with 100s of elements &#8211; you don&#8217;t even need 1000s (although maybe the difference isn&#8217;t as significant if you use chrome, or a fast computer). If you generate the page, why would you plan on making the browser do a significant amount of post-processing after the page is loaded/rendered?<br />
Sure, a simple css selector and bind is elegant, but it&#8217;s hard to expect 10k dom manipulations to perform well. Just make the page the way you like it in the first place and bind stuff dynamically only as needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sixtyseconds</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276310</link>
		<dc:creator>sixtyseconds</dc:creator>
		<pubDate>Wed, 04 Nov 2009 19:52:33 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276310</guid>
		<description>@dperini - You cannot honestly say that at no stage do you need to wait for the DOM to load before attaching events to elements can happen. They simply do not exist before domload. Sure enough; the big players like YUI and jQuery let you attach the events yourself, and maybe NWMatcher does that for you, but behind the scenes all the libraries are doing the same things and are bound by the same rules.

Be that as it may, I only wish/ed to say that there are many ways to do this and we can all agree that the issues in the article would best be resolved using event delegation. Nobody seems to taken issues with the mention of loading 10,000 records initially though - isn&#039;t that a horrible usability concern?</description>
		<content:encoded><![CDATA[<p>@dperini &#8211; You cannot honestly say that at no stage do you need to wait for the DOM to load before attaching events to elements can happen. They simply do not exist before domload. Sure enough; the big players like YUI and jQuery let you attach the events yourself, and maybe NWMatcher does that for you, but behind the scenes all the libraries are doing the same things and are bound by the same rules.</p>
<p>Be that as it may, I only wish/ed to say that there are many ways to do this and we can all agree that the issues in the article would best be resolved using event delegation. Nobody seems to taken issues with the mention of loading 10,000 records initially though &#8211; isn&#8217;t that a horrible usability concern?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dperini</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276309</link>
		<dc:creator>dperini</dc:creator>
		<pubDate>Wed, 04 Nov 2009 19:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276309</guid>
		<description>@sixtyseconds,
no doubt NWMatcher has been the first to do that in a wrapped implementation (you can easily check dates and all), it is true I am not the only one (base2 IS a real library and does that very fast too in JSB).

I don&#039;t have a library myself sorry, however I will be glad to see a speed benchmark on that functionality of Mootools (just to have an indication of what you say).

Both the code presented here and jQuery (and I believe Mootools too) are still depending on a &quot;onload&quot; notification to be able to initialize stuff on the page, NWMatcher avoids that problem completely by letting you pre-declare event binding before the elements really exists on the page.

This has the enormous advantage of avoiding the infamous &quot;onload&quot; problem and/or the &quot;ready&quot; event, they are simply not needed anymore and will allow for a real cross-browser early page enlivenment.</description>
		<content:encoded><![CDATA[<p>@sixtyseconds,<br />
no doubt NWMatcher has been the first to do that in a wrapped implementation (you can easily check dates and all), it is true I am not the only one (base2 IS a real library and does that very fast too in JSB).</p>
<p>I don&#8217;t have a library myself sorry, however I will be glad to see a speed benchmark on that functionality of Mootools (just to have an indication of what you say).</p>
<p>Both the code presented here and jQuery (and I believe Mootools too) are still depending on a &#8220;onload&#8221; notification to be able to initialize stuff on the page, NWMatcher avoids that problem completely by letting you pre-declare event binding before the elements really exists on the page.</p>
<p>This has the enormous advantage of avoiding the infamous &#8220;onload&#8221; problem and/or the &#8220;ready&#8221; event, they are simply not needed anymore and will allow for a real cross-browser early page enlivenment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276307</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Wed, 04 Nov 2009 19:05:25 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276307</guid>
		<description>Jadet,

I didn&#039;t mean to imply that it was fixing all potential issues with $.live, just that it fixes the issue with needlessly polling a selector before attaching to document. It&#039;s an issue that can be solved in a general sense, while what you&#039;re proposing requires more careful planning and knowledge of the document structure. That said, there&#039;s no reason live couldn&#039;t be further extended to allow a parent node and child selector together, but it still wouldn&#039;t give you the finer-grain control you&#039;re probably looking for. For smaller projects, $.live is great; for more complex work, obviously you&#039;ll want to roll your own.</description>
		<content:encoded><![CDATA[<p>Jadet,</p>
<p>I didn&#8217;t mean to imply that it was fixing all potential issues with $.live, just that it fixes the issue with needlessly polling a selector before attaching to document. It&#8217;s an issue that can be solved in a general sense, while what you&#8217;re proposing requires more careful planning and knowledge of the document structure. That said, there&#8217;s no reason live couldn&#8217;t be further extended to allow a parent node and child selector together, but it still wouldn&#8217;t give you the finer-grain control you&#8217;re probably looking for. For smaller projects, $.live is great; for more complex work, obviously you&#8217;ll want to roll your own.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sixtyseconds</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276306</link>
		<dc:creator>sixtyseconds</dc:creator>
		<pubDate>Wed, 04 Nov 2009 18:52:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276306</guid>
		<description>@dperini - Since we&#039;re using this as a forum to promote libraries, let me mention that MooTools also has a match() method as well as a passable event delegation model that addresses the issues mentioned here. NWMatcher isn&#039;t the first or only solution to the problem. :)</description>
		<content:encoded><![CDATA[<p>@dperini &#8211; Since we&#8217;re using this as a forum to promote libraries, let me mention that MooTools also has a match() method as well as a passable event delegation model that addresses the issues mentioned here. NWMatcher isn&#8217;t the first or only solution to the problem. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dperini</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276305</link>
		<dc:creator>dperini</dc:creator>
		<pubDate>Wed, 04 Nov 2009 18:37:04 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276305</guid>
		<description>Folk,
newer Firefox and Webkit nightlies are trying to solve these problems for you tomorrow ! They implement new selectors matcher API:

webkitMatchesSelector() for Webkit browsers
mozMatchesSelector() for Firefox browsers

in the mean time NWMatcher has a match() method, working on browsers that do not have and will never have the above method and it does as fast (or faster) as those new API even on old browsers.

This is what you are looking for, delegation is good, it just doesn&#039;t fit too well with the select() method and binding / wrapping way in current libraries. The match() method is still not appreciated enough by devs, but they will be pushed to use that for complex situations like the one described above.

For event deleagtion I suggest you have a look at NWEvents which is the companion of NWMatcher, these were built as a combo to solve this exact problem. Here is a demo of it&#039;s capabilities:

  http://javascript.nwbox.com/cljs-071809/nwapi/nwapi_test.html

Contrary to what is said above this example handles mouseover/mouseout on complex selectors (:nth-of-type) quite efficiently and if you can have a peek at a profiler session you will quickly understand the requirements for the browsers are very low.

Works on any browser IE6 too.

The reason this can be done is the incredible speed of the underlying match() method for which you can see speed benchmarks here on the FuseJS site:

   http://www.fusejs.com/nwmatcher/match/

The nightly build tests only appears if you have a nightly build to test ;-)

Prototype has already released an adapter for NWMatcher in their current code base, it will be publicly available really soon, I am really looking forward for the outcome of delegation in that wonderful lib.

The suggestion to set an ID on the table and attach a single event to it is still the best pure solution for a one shot trick that solves, if you need to apply this pattern over all your projects then NWEvents+NWmatcher are very helpful.</description>
		<content:encoded><![CDATA[<p>Folk,<br />
newer Firefox and Webkit nightlies are trying to solve these problems for you tomorrow ! They implement new selectors matcher API:</p>
<p>webkitMatchesSelector() for Webkit browsers<br />
mozMatchesSelector() for Firefox browsers</p>
<p>in the mean time NWMatcher has a match() method, working on browsers that do not have and will never have the above method and it does as fast (or faster) as those new API even on old browsers.</p>
<p>This is what you are looking for, delegation is good, it just doesn&#8217;t fit too well with the select() method and binding / wrapping way in current libraries. The match() method is still not appreciated enough by devs, but they will be pushed to use that for complex situations like the one described above.</p>
<p>For event deleagtion I suggest you have a look at NWEvents which is the companion of NWMatcher, these were built as a combo to solve this exact problem. Here is a demo of it&#8217;s capabilities:</p>
<p>  <a href="http://javascript.nwbox.com/cljs-071809/nwapi/nwapi_test.html" rel="nofollow">http://javascript.nwbox.com/cljs-071809/nwapi/nwapi_test.html</a></p>
<p>Contrary to what is said above this example handles mouseover/mouseout on complex selectors (:nth-of-type) quite efficiently and if you can have a peek at a profiler session you will quickly understand the requirements for the browsers are very low.</p>
<p>Works on any browser IE6 too.</p>
<p>The reason this can be done is the incredible speed of the underlying match() method for which you can see speed benchmarks here on the FuseJS site:</p>
<p>   <a href="http://www.fusejs.com/nwmatcher/match/" rel="nofollow">http://www.fusejs.com/nwmatcher/match/</a></p>
<p>The nightly build tests only appears if you have a nightly build to test ;-)</p>
<p>Prototype has already released an adapter for NWMatcher in their current code base, it will be publicly available really soon, I am really looking forward for the outcome of delegation in that wonderful lib.</p>
<p>The suggestion to set an ID on the table and attach a single event to it is still the best pure solution for a one shot trick that solves, if you need to apply this pattern over all your projects then NWEvents+NWmatcher are very helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jadet</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276304</link>
		<dc:creator>Jadet</dc:creator>
		<pubDate>Wed, 04 Nov 2009 18:25:50 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276304</guid>
		<description>@eyelidlessness: That&#039;s no fix, live still checks everything on the document even when some events don&#039;t have to be catched there. live is just not the best way to delegate events. It&#039;s made for ease, if performance was kept in mind there wouldn&#039;t be a live. The proper way to delegate is on parent elements as many have pointed out and ragjunk showed with his snippet, not by doing everything on the document like live does it. jquery could benefit from having a Prototype like event.findElement to allow for a fine grain of control while having maximum performance, it would look like this:

&lt;code&gt;findElement: function(event, expression) {
  var element = event.target;
  if (!expression) return element;
  return $(element).closest(expression)[0];
}
...
// Use it like this. With live() this would be overkill
$(document).ready(function() {
  $(&#039;#parentElement&#039;).bind(&#039;mousemove&#039;, function(event) {
    var element = event.findElement(&#039;li div.remove&#039;);
    if (element) { /* do stuff */ }
  }
});
&lt;/code&gt;

Don&#039;t waste your time trying to fix live().</description>
		<content:encoded><![CDATA[<p>@eyelidlessness: That&#8217;s no fix, live still checks everything on the document even when some events don&#8217;t have to be catched there. live is just not the best way to delegate events. It&#8217;s made for ease, if performance was kept in mind there wouldn&#8217;t be a live. The proper way to delegate is on parent elements as many have pointed out and ragjunk showed with his snippet, not by doing everything on the document like live does it. jquery could benefit from having a Prototype like event.findElement to allow for a fine grain of control while having maximum performance, it would look like this:</p>
<p><code>findElement: function(event, expression) {<br />
  var element = event.target;<br />
  if (!expression) return element;<br />
  return $(element).closest(expression)[0];<br />
}<br />
...<br />
// Use it like this. With live() this would be overkill<br />
$(document).ready(function() {<br />
  $('#parentElement').bind('mousemove', function(event) {<br />
    var element = event.findElement('li div.remove');<br />
    if (element) { /* do stuff */ }<br />
  }<br />
});<br />
</code></p>
<p>Don&#8217;t waste your time trying to fix live().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276303</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Wed, 04 Nov 2009 18:00:59 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276303</guid>
		<description>Oops. In my fix, you should probably add &lt;code&gt;return jq;&lt;/code&gt; to the end of the &lt;code&gt;live&lt;/code&gt; extension.</description>
		<content:encoded><![CDATA[<p>Oops. In my fix, you should probably add <code>return jq;</code> to the end of the <code>live</code> extension.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eyelidlessness</title>
		<link>http://ajaxian.com/archives/jquery-bondage/comment-page-1#comment-276302</link>
		<dc:creator>eyelidlessness</dc:creator>
		<pubDate>Wed, 04 Nov 2009 17:58:09 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=7797#comment-276302</guid>
		<description>Fixing live is really easy.

&lt;code&gt;jQuery.extend({
    live: function(selector, event, callback) {
        var jq = $(document);
        jq.selector = selector;
        jq.live(event, callback);
    }
});&lt;/code&gt;

Then just use &lt;code&gt;$.live(&#039;.someClass&#039;, &#039;someEvent&#039;, someCallback);&lt;/code&gt; No expensive selection, full proper event delegation.</description>
		<content:encoded><![CDATA[<p>Fixing live is really easy.</p>
<p><code>jQuery.extend({<br />
    live: function(selector, event, callback) {<br />
        var jq = $(document);<br />
        jq.selector = selector;<br />
        jq.live(event, callback);<br />
    }<br />
});</code></p>
<p>Then just use <code>$.live('.someClass', 'someEvent', someCallback);</code> No expensive selection, full proper event delegation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

