<?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>
	<pubDate>Tue, 06 Jan 2009 11:33:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-63758</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Sun, 07 Dec 2008 21:43:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63758</guid>
		<description>Hi Nick,

Excellent question! I've updated the post to show an &lt;a href="http://www.learningjquery.com/2008/05/working-with-events-part-2#add-remove" rel="nofollow"&gt;example of adding and removing items&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Hi Nick,</p>
<p>Excellent question! I&#8217;ve updated the post to show an <a href="http://www.learningjquery.com/2008/05/working-with-events-part-2#add-remove" rel="nofollow">example of adding and removing items</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Johns</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-63755</link>
		<dc:creator>Nick Johns</dc:creator>
		<pubDate>Sun, 07 Dec 2008 21:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63755</guid>
		<description>How would you add a second button to REMOVE the line? There are loads of examples of inserting lines but what about removing? thank you for your help.</description>
		<content:encoded><![CDATA[<p>How would you add a second button to REMOVE the line? There are loads of examples of inserting lines but what about removing? thank you for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Q</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-63729</link>
		<dc:creator>Q</dc:creator>
		<pubDate>Thu, 04 Dec 2008 03:13:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63729</guid>
		<description>Well, this seems to be nice and dandy but what if the incoming AJAX based html is not known but contains accordions, thinkboxes, etc, etc.

Is there a generic way of doing this ?

For example I have few areas on the page that bring html via various mechanisms from a remote location - mainly AJAX. I have no idea how the data would look but it may have accordions, tabs, modal boxes(thickbox) - how do I rebind those ?

Calling the document.ready wouldn't do it because the areas that don't refresh are going to bind again creating a nightmare. Ideally would be nice to rebind only the newly refreshed element(divs)

Is there a way to achieve this ?</description>
		<content:encoded><![CDATA[<p>Well, this seems to be nice and dandy but what if the incoming AJAX based html is not known but contains accordions, thinkboxes, etc, etc.</p>
<p>Is there a generic way of doing this ?</p>
<p>For example I have few areas on the page that bring html via various mechanisms from a remote location - mainly AJAX. I have no idea how the data would look but it may have accordions, tabs, modal boxes(thickbox) - how do I rebind those ?</p>
<p>Calling the document.ready wouldn&#8217;t do it because the areas that don&#8217;t refresh are going to bind again creating a nightmare. Ideally would be nice to rebind only the newly refreshed element(divs)</p>
<p>Is there a way to achieve this ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-63695</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Thu, 27 Nov 2008 03:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63695</guid>
		<description>Hi Karl!

Thank you for the quick response. I did understand "Unbind, then Rebind" would fix the problem of producing a multiplier effect, but my question was that I do know understand the behavior of producing a multiplier effect, (e.g. why in some circumstance, when you click the last button of 'I am new', it produces 3 new buttons instead of one?) 
Please see the example at http://www.61dh.com/qna/binding.html, you may know what I was talking about. Sorry for the confusion!

Thanks again!</description>
		<content:encoded><![CDATA[<p>Hi Karl!</p>
<p>Thank you for the quick response. I did understand &#8220;Unbind, then Rebind&#8221; would fix the problem of producing a multiplier effect, but my question was that I do know understand the behavior of producing a multiplier effect, (e.g. why in some circumstance, when you click the last button of &#8216;I am new&#8217;, it produces 3 new buttons instead of one?)<br />
Please see the example at <a href="http://www.61dh.com/qna/binding.html" rel="nofollow">http://www.61dh.com/qna/binding.html</a>, you may know what I was talking about. Sorry for the confusion!</p>
<p>Thanks again!</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-63692</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Wed, 26 Nov 2008 22:47:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63692</guid>
		<description>Hi Adam, 

You need to keep reading this entry all the way through the end, or at least through the section called "Unbind, then Rebind" . It looks like the code you copied comes from the example halfway through the entry.</description>
		<content:encoded><![CDATA[<p>Hi Adam, </p>
<p>You need to keep reading this entry all the way through the end, or at least through the section called &#8220;Unbind, then Rebind&#8221; . It looks like the code you copied comes from the example halfway through the entry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-63691</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Wed, 26 Nov 2008 21:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63691</guid>
		<description>For Re-binding Basics, I tried the example on this page, but got  a problem about producing a multiplier effect. To be better presenting my problem, I cut this example to a new page:
http://www.61dh.com/qna/binding.html

I would appreciate it if someone can help me out. (adamcai@live.com)

Happy Thanksgiving!</description>
		<content:encoded><![CDATA[<p>For Re-binding Basics, I tried the example on this page, but got  a problem about producing a multiplier effect. To be better presenting my problem, I cut this example to a new page:<br />
<a href="http://www.61dh.com/qna/binding.html" rel="nofollow">http://www.61dh.com/qna/binding.html</a></p>
<p>I would appreciate it if someone can help me out. (adamcai@live.com)</p>
<p>Happy Thanksgiving!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: &#160; jQuery Autocomplete Plugin&#160;by&#160;bigredswitch</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-63479</link>
		<dc:creator>&#160; jQuery Autocomplete Plugin&#160;by&#160;bigredswitch</dc:creator>
		<pubDate>Mon, 10 Nov 2008 00:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-63479</guid>
		<description>[...] were. Turns out that jQuery has a mechanism where you can namespace your events. Here is another writeup about it. Nice [...]</description>
		<content:encoded><![CDATA[<p>[...] were. Turns out that jQuery has a mechanism where you can namespace your events. Here is another writeup about it. Nice [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc Davenport</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-60916</link>
		<dc:creator>Marc Davenport</dc:creator>
		<pubDate>Thu, 02 Oct 2008 19:26:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-60916</guid>
		<description>Great posts Karl! I'm still new to jQuery, but it is coming along quick.   One thing I'm still not equipped to do is make the decision between event delegation and re-binding.  Event Delegation seems to have great performance characteristics but ties you to a couple specific named elements. Re-binding would allow you to make completely dynamic nests of divs.  Is there one you prefer?

I have a situation where I'll be adding several divs that I want to have a certain behavior. Rather than go through re-binding them, I was thinking of creating a hidden div that has all the behavior bound to it, and then when I need to "add" the div, I'll just use clone(true) on the hidden div and change the id and remove my "hidden" class. This way I don't have to spend much time worrying about rebinding. Does this approach have merit, or is there a drawback that I'm not considering?</description>
		<content:encoded><![CDATA[<p>Great posts Karl! I&#8217;m still new to jQuery, but it is coming along quick.   One thing I&#8217;m still not equipped to do is make the decision between event delegation and re-binding.  Event Delegation seems to have great performance characteristics but ties you to a couple specific named elements. Re-binding would allow you to make completely dynamic nests of divs.  Is there one you prefer?</p>
<p>I have a situation where I&#8217;ll be adding several divs that I want to have a certain behavior. Rather than go through re-binding them, I was thinking of creating a hidden div that has all the behavior bound to it, and then when I need to &#8220;add&#8221; the div, I&#8217;ll just use clone(true) on the hidden div and change the id and remove my &#8220;hidden&#8221; class. This way I don&#8217;t have to spend much time worrying about rebinding. Does this approach have merit, or is there a drawback that I&#8217;m not considering?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joao Carlos</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-58620</link>
		<dc:creator>Joao Carlos</dc:creator>
		<pubDate>Thu, 25 Sep 2008 23:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-58620</guid>
		<description>Hello there,

Regarding Bind/unbind this article bring me more confusion than what it solves.

Why do you use Append methods (addItemFinal, .append, etc,etc) when you can explain it more generally with, after you load your external data, just type the bind method again, period!

Example :
&lt;pre&gt;&lt;code&gt;
function actualizarLinks() 
{
   $.get("index.php", { page: "links" , returnType: "html", ajax:"1" }, function(data){ 
					 $("#links").html(data); 
					 $('#refreshLinks').bind('click', actualizarLinks);	
				} 
	 ); 							

}
$('#refreshLinks').bind('click', actualizarLinks);

&lt;/code&gt;&lt;/pre&gt;

Explained:

The last line simply binds the click button of #refreshLinks to the function actualizarLinks for the function to called.

Inside the function, we call request the page with ajax, and update our #links with the data returned, then, we just rebind (bind again), the click method of #refreshLinks to the actualizarLinks function.

Hope this clears any future confusion, like the one i had.</description>
		<content:encoded><![CDATA[<p>Hello there,</p>
<p>Regarding Bind/unbind this article bring me more confusion than what it solves.</p>
<p>Why do you use Append methods (addItemFinal, .append, etc,etc) when you can explain it more generally with, after you load your external data, just type the bind method again, period!</p>
<p>Example :</p>
<pre><code>
function actualizarLinks()
{
   $.get("index.php", { page: "links" , returnType: "html", ajax:"1" }, function(data){
					 $("#links").html(data);
					 $('#refreshLinks').bind('click', actualizarLinks);
				}
	 ); 							

}
$('#refreshLinks').bind('click', actualizarLinks);

</code></pre>
<p>Explained:</p>
<p>The last line simply binds the click button of #refreshLinks to the function actualizarLinks for the function to called.</p>
<p>Inside the function, we call request the page with ajax, and update our #links with the data returned, then, we just rebind (bind again), the click method of #refreshLinks to the actualizarLinks function.</p>
<p>Hope this clears any future confusion, like the one i had.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tahir</title>
		<link>http://www.learningjquery.com/2008/05/working-with-events-part-2/comment-page-1#comment-54616</link>
		<dc:creator>Tahir</dc:creator>
		<pubDate>Thu, 04 Sep 2008 07:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningjquery.com/2008/05/working-with-events-part-2#comment-54616</guid>
		<description>Sorry for my delay I was busy in other things.

&lt;pre&gt;&lt;code&gt;
function addItemFinal() {
	var $newLi = $(' &#60;li class="special" &#62;special and new  &#60;button &#62;I am new &#60;/button &#62; &#60;/li &#62;');
	$(this).parent().after($newLi);
	$('#list8 li.special button')
	  .unbind('click', addItemFinal)
	  .bind('click', addItemFinal);
}
$(document).ready(function() {
$('#list8 li.special button').bind('click', addItemFinal);
  // non-rebinding click handler
  $('#list8 li.special button').click(function() {
	$(this).after(' pressed');
  });
});
&lt;/code&gt;&lt;/pre&gt;

Ok Here is my question.
if there is a list like in the document.
&lt;strong&gt;$('#list8 li.special button').bind('click', addItemFinal);&lt;/strong&gt;
and after that there is another list with the same name and both loaded at the same time. It apply the effect on first one. but does not work on the second one Why. I resolved it like this
&lt;strong&gt;$('#list8 li.special button').bind('click', addItemFinal);
$('#list9 li.special button').bind('click', addItemFinal);&lt;/strong&gt;

while it should work like this.
&lt;strong&gt;$('#list8 li.special button').bind('click', addItemFinal);&lt;/strong&gt;

As it is said that Effect is applied to all the DOM elements as with the same reference.
I tested other sort of things with the same concept like changing colors etc those thing works fine (not in this example).</description>
		<content:encoded><![CDATA[<p>Sorry for my delay I was busy in other things.</p>
<pre><code>
function addItemFinal() {
	var $newLi = $(' &lt;li class="special" &gt;special and new  &lt;button &gt;I am new &lt;/button &gt; &lt;/li &gt;');
	$(this).parent().after($newLi);
	$('#list8 li.special button')
	  .unbind('click', addItemFinal)
	  .bind('click', addItemFinal);
}
$(document).ready(function() {
$('#list8 li.special button').bind('click', addItemFinal);
  // non-rebinding click handler
  $('#list8 li.special button').click(function() {
	$(this).after(' pressed');
  });
});
</code></pre>
<p>Ok Here is my question.<br />
if there is a list like in the document.<br />
<strong>$(&#8217;#list8 li.special button&#8217;).bind(&#8217;click&#8217;, addItemFinal);</strong><br />
and after that there is another list with the same name and both loaded at the same time. It apply the effect on first one. but does not work on the second one Why. I resolved it like this<br />
<strong>$(&#8217;#list8 li.special button&#8217;).bind(&#8217;click&#8217;, addItemFinal);<br />
$(&#8217;#list9 li.special button&#8217;).bind(&#8217;click&#8217;, addItemFinal);</strong></p>
<p>while it should work like this.<br />
<strong>$(&#8217;#list8 li.special button&#8217;).bind(&#8217;click&#8217;, addItemFinal);</strong></p>
<p>As it is said that Effect is applied to all the DOM elements as with the same reference.<br />
I tested other sort of things with the same concept like changing colors etc those thing works fine (not in this example).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
