<?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.live(&quot;click&quot;) Gotcha</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Thu, 11 Sep 2014 09:58:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mike Cotton</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-265235</link>
		<dc:creator>Mike Cotton</dc:creator>
		<pubDate>Thu, 14 Jul 2011 19:33:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-265235</guid>
		<description>I learned something on a project I was working on the other day. I was having trouble figuring out whether to use the which event or the button event when trying to detect what button was clicked in different browsers. Using the button event values returned inconsistent results. Using the which event value was more consistent but IE always returned it as undefined/null. Here is what I did to make it work for me.

&lt;pre&gt;$(#target&quot;).live(&quot;mouseup&quot;, function(event){
     if(event.which == null){
          // this is ie, left button is 1, right button is 2, middle button is 4
          if(event.button == 1){
               // left button clicked
               doSomething();
          }
     }else{
          //all other browsers, left which is 1, right which is 3, middle which is 2
          if(event.which == 1){
               // left button clicked
               doSomething();
          }
     }
});
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I learned something on a project I was working on the other day. I was having trouble figuring out whether to use the which event or the button event when trying to detect what button was clicked in different browsers. Using the button event values returned inconsistent results. Using the which event value was more consistent but IE always returned it as undefined/null. Here is what I did to make it work for me.</p>
<pre>$(#target").live("mouseup", function(event){
     if(event.which == null){
          // this is ie, left button is 1, right button is 2, middle button is 4
          if(event.button == 1){
               // left button clicked
               doSomething();
          }
     }else{
          //all other browsers, left which is 1, right which is 3, middle which is 2
          if(event.which == 1){
               // left button clicked
               doSomething();
          }
     }
});
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Candace Camarillo</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-223262</link>
		<dc:creator>Candace Camarillo</dc:creator>
		<pubDate>Mon, 18 Oct 2010 18:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-223262</guid>
		<description>I love searching for bug reports and finding you :-)</description>
		<content:encoded><![CDATA[<p>I love searching for bug reports and finding you :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-206336</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Thu, 25 Feb 2010 17:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-206336</guid>
		<description>@Resourcednet

Yes, that would let you synthesize when clicks may happen based on mouse movements and focus changes, but it&#039;s not detecting Adsense clicks.  Ben calls out several places where it&#039;ll fail to do what you want, not to mention it doesn&#039;t tell you anything about the supposed click (e.g., the target), just that one probably happened.</description>
		<content:encoded><![CDATA[<p>@Resourcednet</p>
<p>Yes, that would let you synthesize when clicks may happen based on mouse movements and focus changes, but it's not detecting Adsense clicks.  Ben calls out several places where it'll fail to do what you want, not to mention it doesn't tell you anything about the supposed click (e.g., the target), just that one probably happened.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Resourcednet</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-206288</link>
		<dc:creator>Resourcednet</dc:creator>
		<pubDate>Thu, 25 Feb 2010 06:55:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-206288</guid>
		<description>How about this? http://www.bennadel.com/blog/1752-Tracking-Google-AdSense-Clicks-With-jQuery-And-ColdFusion.htm</description>
		<content:encoded><![CDATA[<p>How about this? <a href="http://www.bennadel.com/blog/1752-Tracking-Google-AdSense-Clicks-With-jQuery-And-ColdFusion.htm" rel="nofollow">http://www.bennadel.com/blog/1752-Tracking-Google-AdSense-Clicks-With-jQuery-And-ColdFusion.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-206282</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Thu, 25 Feb 2010 06:19:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-206282</guid>
		<description>@Resourcednet

No, you can&#039;t detect Adsense clicks; they&#039;re loaded in an IFRAME with a document from a different domain which is consequently inaccessible from your page&#039;s JS.</description>
		<content:encoded><![CDATA[<p>@Resourcednet</p>
<p>No, you can't detect Adsense clicks; they're loaded in an IFRAME with a document from a different domain which is consequently inaccessible from your page's JS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Resourcednet</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-206281</link>
		<dc:creator>Resourcednet</dc:creator>
		<pubDate>Thu, 25 Feb 2010 05:50:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-206281</guid>
		<description>Is this script possible to detect Adsense click?</description>
		<content:encoded><![CDATA[<p>Is this script possible to detect Adsense click?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeffery</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-202052</link>
		<dc:creator>jeffery</dc:creator>
		<pubDate>Mon, 11 Jan 2010 04:22:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-202052</guid>
		<description>same behaviour with the third mouse button.</description>
		<content:encoded><![CDATA[<p>same behaviour with the third mouse button.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Tsadok</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-192670</link>
		<dc:creator>Daniel Tsadok</dc:creator>
		<pubDate>Tue, 06 Oct 2009 19:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-192670</guid>
		<description>event.which is returning undefined in IE7...</description>
		<content:encoded><![CDATA[<p>event.which is returning undefined in IE7&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-187682</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Thu, 06 Aug 2009 14:44:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-187682</guid>
		<description>The &#039;button&#039; event attribute is not normalized by jQuery. But it does normalize event.which to be 1,2,3 depending on the button clicked (1=left,2=middle,3=right).

So use event.which instead of event.button.</description>
		<content:encoded><![CDATA[<p>The 'button' event attribute is not normalized by jQuery. But it does normalize event.which to be 1,2,3 depending on the button clicked (1=left,2=middle,3=right).</p>
<p>So use event.which instead of event.button.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>https://www.barneyb.com/barneyblog/2009/04/09/jquery-live-click-gotcha/comment-page-1/#comment-174370</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Tue, 21 Apr 2009 20:21:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/?p=815#comment-174370</guid>
		<description>nirvana,

If that&#039;s the case (I don&#039;t know, offhand), jQuery is isolating me (the developer) from it perfectly.  Hit http://barneyb.com/r/jquery_live_button.cfm in whatever browser you want for a demo.  FF and IE both return zeros for both live and click events.</description>
		<content:encoded><![CDATA[<p>nirvana,</p>
<p>If that's the case (I don't know, offhand), jQuery is isolating me (the developer) from it perfectly.  Hit <a href="http://barneyb.com/r/jquery_live_button.cfm" rel="nofollow">http://barneyb.com/r/jquery_live_button.cfm</a> in whatever browser you want for a demo.  FF and IE both return zeros for both live and click events.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
