<?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: Working with Events, part 2</title>
	<atom:link href="http://www.learningjquery.com/2008/05/working-with-events-part-2/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com/2008/05/working-with-events-part-2</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Wed, 08 Feb 2012 13:50:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Having trouble with event binding for dynamically added stuff &#124; deepinphp.com</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-83551</link>
		<dc:creator>Having trouble with event binding for dynamically added stuff &#124; deepinphp.com</dc:creator>
		<pubDate>Mon, 14 Mar 2011 01:53:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-83551</guid>
		<description>[...] been reading learningjquery and messing with livequery plugin, but no avail. I understand the problem, just not able to solve [...]</description>
		<content:encoded><![CDATA[<p>[...] been reading learningjquery and messing with livequery plugin, but no avail. I understand the problem, just not able to solve [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-83060</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Wed, 10 Nov 2010 14:05:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-83060</guid>
		<description>Great article!

I have 1000s of events on some pages, lots of them invoke ajax calls, spreadsheet like functionality. I zoom-in and out of &quot;product&quot; to ser their ajax retrieved details (ASP.Net ascx file returned). I rebind my events when appending the new details to the DOM. I use .Empty() to clear the details when &quot;zooming-out&quot;. Would resources leak without explicitly destroying events?</description>
		<content:encoded><![CDATA[<p>Great article!</p>
<p>I have 1000s of events on some pages, lots of them invoke ajax calls, spreadsheet like functionality. I zoom-in and out of &#8220;product&#8221; to ser their ajax retrieved details (ASP.Net ascx file returned). I rebind my events when appending the new details to the DOM. I use .Empty() to clear the details when &#8220;zooming-out&#8221;. Would resources leak without explicitly destroying events?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-83059</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Wed, 10 Nov 2010 14:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-83059</guid>
		<description>add classes:
&lt;div id=&quot;someId&quot; class=&quot;newDivs&quot;&gt;&lt;/div&gt;

$(&#039;.newDivs&#039;).bind(....</description>
		<content:encoded><![CDATA[<p>add classes:</p>
<div id="someId" class="newDivs"></div>
<p>$(&#8216;.newDivs&#8217;).bind(&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-82995</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 28 Oct 2010 15:12:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-82995</guid>
		<description>Hi all,

I&#039;m new to JQuery/AJAX and having a tough time understanding how to rebind my onclick event handler.

My page is basically a results page with pagination. The page number links appear in a div called &#039;pagination&#039; and the results appear in a div called &#039;results&#039;.

I use JQuery to cycle through each href anchor in the pagination div and attach an onclick event handler to each. Clicking on an anchor in the pagination fires an ajax load to update the results.

Here is my code:

&lt;pre&gt;&lt;code&gt;$(&#039;#pagination div a&#039;).each(function(i,item){
   $(this).click(function(){
   var offsetNo = $(this).attr(&#039;href&#039;).replace(&#039;http://www.mysite.com/news?&amp;&#039;, &#039;&#039;);
   $(&#039;#results&#039;).load(&#039;results.php?&#039;+offsetNo, function() {
      //call back if needed
   });
   return false;
   });
});
&lt;/code&gt;&lt;/pre&gt;

This works only the once.  After the ajax update of &#039;results&#039;, the binding is lost.  How can I change my code to fix this?
P.S. I&#039;ve tried the 3 plugins mentioned about, but had no luck with them, so I thought it best to find a solution without them, which might better help me understand how it works.</description>
		<content:encoded><![CDATA[<p>Hi all,</p>
<p>I&#8217;m new to JQuery/AJAX and having a tough time understanding how to rebind my onclick event handler.</p>
<p>My page is basically a results page with pagination. The page number links appear in a div called &#8216;pagination&#8217; and the results appear in a div called &#8216;results&#8217;.</p>
<p>I use JQuery to cycle through each href anchor in the pagination div and attach an onclick event handler to each. Clicking on an anchor in the pagination fires an ajax load to update the results.</p>
<p>Here is my code:</p>
<pre><code>$('#pagination div a').each(function(i,item){
   $(this).click(function(){
   var offsetNo = $(this).attr('href').replace('<a href="http://www.mysite.com/news?&#038;&#039;" rel="nofollow">http://www.mysite.com/news?&#038;&#039;</a>, '');
   $('#results').load('results.php?'+offsetNo, function() {
      //call back if needed
   });
   return false;
   });
});
</code></pre>
<p>This works only the once.  After the ajax update of &#8216;results&#8217;, the binding is lost.  How can I change my code to fix this?<br />
P.S. I&#8217;ve tried the 3 plugins mentioned about, but had no luck with them, so I thought it best to find a solution without them, which might better help me understand how it works.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-80802</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Tue, 13 Jul 2010 20:37:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-80802</guid>
		<description>Hi,

My AJAX returns several different divs and I don&#039;t know what the ID will be. For example:

&lt;pre&gt;&lt;code&gt;
&lt;div id=&quot;div245&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;div225&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;div25&quot;&gt;&lt;/div&gt;
&lt;/code&gt;&lt;/pre&gt;

How can I bind these when I don&#039;t know what the DIV ID will be?

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>My AJAX returns several different divs and I don&#8217;t know what the ID will be. For example:</p>
<pre><code>
&lt;div id="div245"&gt;&lt;/div&gt;
&lt;div id="div225"&gt;&lt;/div&gt;
&lt;div id="div25"&gt;&lt;/div&gt;
</code></pre>
<p>How can I bind these when I don&#8217;t know what the DIV ID will be?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seb</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-80759</link>
		<dc:creator>Seb</dc:creator>
		<pubDate>Thu, 08 Jul 2010 07:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-80759</guid>
		<description>Joao Carlos - buddy - you&#039;ve saved my life - I&#039;ve been looking for this kind of solution for bloody hours! Many thanks to everyone here - great contribution!</description>
		<content:encoded><![CDATA[<p>Joao Carlos &#8211; buddy &#8211; you&#8217;ve saved my life &#8211; I&#8217;ve been looking for this kind of solution for bloody hours! Many thanks to everyone here &#8211; great contribution!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Strony Szczecin</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-80103</link>
		<dc:creator>Strony Szczecin</dc:creator>
		<pubDate>Fri, 23 Apr 2010 19:08:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-80103</guid>
		<description>Thanks so much for this post as it saved me a lot of time and shaked to stop thinking about a silly idea</description>
		<content:encoded><![CDATA[<p>Thanks so much for this post as it saved me a lot of time and shaked to stop thinking about a silly idea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-79751</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Sun, 28 Feb 2010 01:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-79751</guid>
		<description>Hi Dakota, 
.live() is completely different from .clone(true). The .live() method sets up an event handler that &quot;listens&quot; for some kind of action to take place (such as a click) at which point the handler is triggered. The .clone(true) method makes a copy of elements specified by whatever is in the jQuery set at the time ( for example, all divs, if you do $(&#039;div&#039;).clone(true) ). By passing in true, it also copies events and data that are associated with those elements. 

Hope that makes sense.</description>
		<content:encoded><![CDATA[<p>Hi Dakota,<br />
.live() is completely different from .clone(true). The .live() method sets up an event handler that &#8220;listens&#8221; for some kind of action to take place (such as a click) at which point the handler is triggered. The .clone(true) method makes a copy of elements specified by whatever is in the jQuery set at the time ( for example, all divs, if you do $(&#8216;div&#8217;).clone(true) ). By passing in true, it also copies events and data that are associated with those elements. </p>
<p>Hope that makes sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishu</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-79750</link>
		<dc:creator>Vishu</dc:creator>
		<pubDate>Sat, 27 Feb 2010 11:36:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-79750</guid>
		<description>I was actually trying to bind a click even to the link tag generated from a php file(via jquery ajax call) which itself was called by the click event of a button on the home page, so after the php generated content(the link) asynchronously, the click event bound to the link didn&#039;t work, but my prob was solved by merely calling my jquery script again in the called php..

...I doubt if I make any sense above :P</description>
		<content:encoded><![CDATA[<p>I was actually trying to bind a click even to the link tag generated from a php file(via jquery ajax call) which itself was called by the click event of a button on the home page, so after the php generated content(the link) asynchronously, the click event bound to the link didn&#8217;t work, but my prob was solved by merely calling my jquery script again in the called php..</p>
<p>&#8230;I doubt if I make any sense above :P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dakota</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-79736</link>
		<dc:creator>Dakota</dc:creator>
		<pubDate>Tue, 23 Feb 2010 02:30:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-79736</guid>
		<description>Hi Karl, Is the .live() method in 1.3ish just an alias for .clone(true), or does it do other stuff as well?</description>
		<content:encoded><![CDATA[<p>Hi Karl, Is the .live() method in 1.3ish just an alias for .clone(true), or does it do other stuff as well?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced (User agent is rejected)
Database Caching 8/20 queries in 0.006 seconds using disk: basic
Object Caching 371/376 objects using disk: basic
Content Delivery Network via learningjquery.kswedberg.netdna-cdn.com

Served from: www.learningjquery.com @ 2012-02-08 14:30:01 -->
