<?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 function context, &#8220;apply&#8221; method and lost &#8220;this&#8221; object</title>
	<atom:link href="http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/</link>
	<description>C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks</description>
	<lastBuildDate>Tue, 31 Jan 2012 06:04:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: fellow programmer</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-3548</link>
		<dc:creator>fellow programmer</dc:creator>
		<pubDate>Fri, 02 Apr 2010 21:46:53 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-3548</guid>
		<description>[...] some time to review your code. Walk him through your code, just a high level introduction. Ask ...Javascript function context, apply method and lost this ...Javascript tips on running functions in other context, using apply method, creating javascript [...]</description>
		<content:encoded><![CDATA[<div style="color:#008200">
<p>[...] some time to review your code. Walk him through your code, just a high level introduction. Ask &#8230;Javascript function context, apply method and lost this &#8230;Javascript tips on running functions in other context, using apply method, creating javascript [...]</p>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: M@</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-1963</link>
		<dc:creator>M@</dc:creator>
		<pubDate>Mon, 02 Nov 2009 22:35:15 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-1963</guid>
		<description>This solution can be cleaned up even further by putting getContextFunc into function thusly:
Function.prototype.inContext = function(context){
  var func = this;
  return function(){
    return func.apply(context, arguments);
  };
};

So that when you want to call it you can simply say:
getRemoteCircumference: function(url) {  
          $.getJSON(url, this.getCircumference.inContext(this));  
       }</description>
		<content:encoded><![CDATA[<p>This solution can be cleaned up even further by putting getContextFunc into function thusly:<br />
Function.prototype.inContext = function(context){<br />
  var func = this;<br />
  return function(){<br />
    return func.apply(context, arguments);<br />
  };<br />
};</p>
<p>So that when you want to call it you can simply say:<br />
getRemoteCircumference: function(url) {<br />
          $.getJSON(url, this.getCircumference.inContext(this));<br />
       }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-07-15 &#171; pabloidz</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-95</link>
		<dc:creator>links for 2009-07-15 &#171; pabloidz</dc:creator>
		<pubDate>Wed, 15 Jul 2009 12:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-95</guid>
		<description>[...] Javascript function context, &quot;apply&quot; method and lost &quot;this&quot; object .NET Tips &amp; Tricks (tags: javascript) [...]</description>
		<content:encoded><![CDATA[<div style="color:#008200">
<p>[...] Javascript function context, &quot;apply&quot; method and lost &quot;this&quot; object .NET Tips &amp; Tricks (tags: javascript) [...]</p>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maxim</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-82</link>
		<dc:creator>Maxim</dc:creator>
		<pubDate>Tue, 14 Jul 2009 04:52:28 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-82</guid>
		<description>&lt;a href=&quot;#comment-70&quot; rel=&quot;nofollow&quot;&gt;@Brandon &lt;/a&gt; 
Sure you can, but you will not be able to use &lt;strong&gt;&lt;em&gt;this&lt;/em&gt;&lt;/strong&gt; in getCircumference cause it will run in the context of AJAX request object.
There is a difference between &lt;em&gt;mathObj.getCircumference()&lt;/em&gt; (calling object method) and &lt;em&gt;mathObj.getCircumference&lt;/em&gt; (passing function reference as callback) this is what probably get you confused</description>
		<content:encoded><![CDATA[<p><a href="#comment-70" rel="nofollow">@Brandon </a><br />
Sure you can, but you will not be able to use <strong><em>this</em></strong> in getCircumference cause it will run in the context of AJAX request object.<br />
There is a difference between <em>mathObj.getCircumference()</em> (calling object method) and <em>mathObj.getCircumference</em> (passing function reference as callback) this is what probably get you confused</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-70</link>
		<dc:creator>Brandon</dc:creator>
		<pubDate>Mon, 13 Jul 2009 21:54:10 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-70</guid>
		<description>I might be missing something but couldn&#039;t you just use:

$.getJSON(url, mathObj.getCircumference));</description>
		<content:encoded><![CDATA[<p>I might be missing something but couldn&#8217;t you just use:</p>
<p>$.getJSON(url, mathObj.getCircumference));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javascript pseudo protocol (is EVIL) or is it? &#124; .NET Tips &#38; Tricks</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-49</link>
		<dc:creator>Javascript pseudo protocol (is EVIL) or is it? &#124; .NET Tips &#38; Tricks</dc:creator>
		<pubDate>Sun, 12 Jul 2009 18:36:50 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-49</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<div style="color:#008200">
<p>[...]  [...]</p>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Twitted by kossovskynet</title>
		<link>http://kossovsky.net/index.php/2009/07/function-context-and-apply-function/comment-page-1/#comment-45</link>
		<dc:creator>Twitted by kossovskynet</dc:creator>
		<pubDate>Sun, 12 Jul 2009 10:57:04 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=519#comment-45</guid>
		<description>[...] This post was Twitted by kossovskynet [...]</description>
		<content:encoded><![CDATA[<div style="color:#008200">
<p>[...] This post was Twitted by kossovskynet [...]</p>
</div>
]]></content:encoded>
	</item>
</channel>
</rss>

