<?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: JavaScript Scope</title>
	<atom:link href="http://happygiraffe.net/blog/2008/08/27/javascript-scope/feed/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog/2008/08/27/javascript-scope/</link>
	<description></description>
	<lastBuildDate>Tue, 16 Feb 2010 16:00:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dom</title>
		<link>http://happygiraffe.net/blog/2008/08/27/javascript-scope/comment-page-1/#comment-778</link>
		<dc:creator>dom</dc:creator>
		<pubDate>Thu, 28 Aug 2008 09:23:38 +0000</pubDate>
		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1333#comment-778</guid>
		<description>@märtin: You&#039;re absolutely correct.  But this is trivial example to demonstrate scope within JavaScript, not show how to access stuff within events.

Thanks for the tip though, I&#039;ll have to remember that one. :)</description>
		<content:encoded><![CDATA[<p>@märtin: You&#8217;re absolutely correct.  But this is trivial example to demonstrate scope within JavaScript, not show how to access stuff within events.</p>
<p>Thanks for the tip though, I&#8217;ll have to remember that one. <img src='http://happygiraffe.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: märtin</title>
		<link>http://happygiraffe.net/blog/2008/08/27/javascript-scope/comment-page-1/#comment-777</link>
		<dc:creator>märtin</dc:creator>
		<pubDate>Thu, 28 Aug 2008 07:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1333#comment-777</guid>
		<description>when you just want to alert the item (element) to which the event is attached you can easily refer to &quot;this&quot; (or some property of your event object, depending on toolkit used) inside the event function. the attempt to pass an element to its own event seems pointless to me. When i need to access some data from within an event i usually fill the element&#039;s rel-attr with a key(number) needed to access the corresponding data from some array/obj.

bäst

märtin</description>
		<content:encoded><![CDATA[<p>when you just want to alert the item (element) to which the event is attached you can easily refer to &#8220;this&#8221; (or some property of your event object, depending on toolkit used) inside the event function. the attempt to pass an element to its own event seems pointless to me. When i need to access some data from within an event i usually fill the element&#8217;s rel-attr with a key(number) needed to access the corresponding data from some array/obj.</p>
<p>bäst</p>
<p>märtin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dom</title>
		<link>http://happygiraffe.net/blog/2008/08/27/javascript-scope/comment-page-1/#comment-772</link>
		<dc:creator>dom</dc:creator>
		<pubDate>Wed, 27 Aug 2008 18:55:55 +0000</pubDate>
		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1333#comment-772</guid>
		<description>@Simon: I certainly could do that (and probably would in my own code, though I confess it doesn&#039;t scan that well to me).  But it&#039;s an aside here.  The main point is that JavaScript doesn&#039;t give you new scope when you open up a pair of curlies.</description>
		<content:encoded><![CDATA[<p>@Simon: I certainly could do that (and probably would in my own code, though I confess it doesn&#8217;t scan that well to me).  But it&#8217;s an aside here.  The main point is that JavaScript doesn&#8217;t give you new scope when you open up a pair of curlies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Proctor</title>
		<link>http://happygiraffe.net/blog/2008/08/27/javascript-scope/comment-page-1/#comment-771</link>
		<dc:creator>Simon Proctor</dc:creator>
		<pubDate>Wed, 27 Aug 2008 18:37:23 +0000</pubDate>
		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1333#comment-771</guid>
		<description>Why not just use a closure inline?

&lt;pre lang=&quot;javascript&quot;&gt;
  item.onclick = function( tmpitem ) {
       return function() { alert(&quot;item is &quot; + tmpitem); }
      }(item);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Why not just use a closure inline?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> tmpitem <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;item is &quot;</span> <span style="color: #339933;">+</span> tmpitem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: dom</title>
		<link>http://happygiraffe.net/blog/2008/08/27/javascript-scope/comment-page-1/#comment-770</link>
		<dc:creator>dom</dc:creator>
		<pubDate>Wed, 27 Aug 2008 09:08:19 +0000</pubDate>
		<guid isPermaLink="false">http://happygiraffe.net/blog/?p=1333#comment-770</guid>
		<description>Please excuse the direct assignment to &lt;code&gt;onclick&lt;/code&gt;.  Under normal circumstances I would use some form of &lt;code&gt;addEvent()&lt;/code&gt;…</description>
		<content:encoded><![CDATA[<p>Please excuse the direct assignment to <code>onclick</code>.  Under normal circumstances I would use some form of <code>addEvent()</code>…</p>
]]></content:encoded>
	</item>
</channel>
</rss>
