<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx</link><description>The problem is the following... You want to attach a handler to a DOM event but you want some information to remain associated with it. Let's say for example that the handler is a method of an object that makes use of the "this" pointer somewhere in its</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Quizz JavaScript - reponse : objet et abonnement d'evenement</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#3495945</link><pubDate>Mon, 13 Aug 2007 23:46:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3495945</guid><dc:creator>Atteint de Javascriptite aiguë [Cyril DURAND]</dc:creator><author>Atteint de Javascriptite aiguë [Cyril DURAND]</author><description>&lt;p&gt;Voici les r&amp;#233;ponses au Quizz JavaScript : objet et abonnement d'&amp;#233;v&amp;#233;nement Le probl&amp;#232;me &amp;#233;tait encore &amp;#224; cause&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3495945" width="1" height="1"&gt;</description></item><item><title>Quizz JavaScript : réponse gestionnaire d'evenements et boucle</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#3481226</link><pubDate>Sun, 12 Aug 2007 14:55:22 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3481226</guid><dc:creator>Atteint de Javascriptite aiguë [Cyril DURAND]</dc:creator><author>Atteint de Javascriptite aiguë [Cyril DURAND]</author><description>&lt;p&gt;Voici la r&amp;#233;ponse&amp;#160;au Quizz JavaScript - gestionnaire d&amp;#39;evenements et boucles . Pour rappel la question&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3481226" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#3192145</link><pubDate>Tue, 17 Jul 2007 18:00:38 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3192145</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;t3knomanser: yes, what you're not seeing is that this is implemented using closures. If you're confortable with using closures directly, that's fine but you need to be careful as you may inadvertently attach more context than you need and even create hard to find memory leaks in IE. The methods presented here are more convenient, they hide a concept that is difficult or unknown to many developers who are new to JavaScript, and they only capture in the closure what little context *you* decide is useful.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3192145" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#3189425</link><pubDate>Tue, 17 Jul 2007 13:17:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:3189425</guid><dc:creator>t3knomanser</dc:creator><author>t3knomanser</author><description>&lt;p&gt;Is there any reason to not just use closures? This seems like a pretty uninteresting method. Closures do this, and a bunch more. Is there something I&amp;#39;m not seeing?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=3189425" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#2727424</link><pubDate>Mon, 04 Jun 2007 21:22:01 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2727424</guid><dc:creator>Joel Rumerman</dc:creator><author>Joel Rumerman</author><description>Hey Bertrand,

Hope all is well. 

I&amp;#39;ve used this technique before for web services as Sean mentioned above and for attaching events to external objects (i.e. the page request manager). 

Thx for confirming that this was the correct way to maintain context with the current object. 

What else can this technique do for us (the advanced topics you hinted at)? I&amp;#39;d love a follow up post on this topic.

Thx, Joel&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2727424" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#2213328</link><pubDate>Wed, 11 Apr 2007 16:36:01 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2213328</guid><dc:creator>Sean Kinsey</dc:creator><author>Sean Kinsey</author><description>&lt;p&gt;This is also usefull when calling webservices with a callback handler. By using a delegate the callback will be executed in the same context as the function calling the webservice, something that is extremely usefull when calling webservices from within custom objects.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2213328" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#2213152</link><pubDate>Wed, 11 Apr 2007 15:50:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2213152</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;Muhammad: you'll have to ask Telerik...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2213152" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#2213099</link><pubDate>Wed, 11 Apr 2007 15:40:35 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2213099</guid><dc:creator>Muhammad Mosa</dc:creator><author>Muhammad Mosa</author><description>&lt;p&gt;Well, I built an AJAX Control, it is a simple Custom ComboBox. if acctually uses javascript extensions provided by ASP.NET AJAX Framwork to show and hide and select items from a simle list control &amp;quot;&amp;lt;select&amp;gt;&amp;quot;. this control is working fine with UpdatePanel as it rais post back and also . I tried to use it withing Telerik Ajax Panel, and with Telerik Ajax Manager. I'me not sure if you used them before. With Telerik Ajax Manager displays a Javascript error and with Ajax Panel it is not updating panel content as well as stops to response to javascript events e.g, click on text box to show the list box etc...&lt;/p&gt;
&lt;p&gt;Do you have any idea about that!?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2213099" width="1" height="1"&gt;</description></item><item><title>re: How to keep some context attached to a JavaScript event handler?</title><link>http://weblogs.asp.net/bleroy/archive/2007/04/10/how-to-keep-some-context-attached-to-a-javascript-event-handler.aspx#2210786</link><pubDate>Wed, 11 Apr 2007 06:51:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2210786</guid><dc:creator>Aleksey Fomichenko</dc:creator><author>Aleksey Fomichenko</author><description>&lt;p&gt;Great article! This really helps.&lt;/p&gt;
&lt;p&gt;What I used to do before reading this post is:&lt;/p&gt;
&lt;p&gt;var self = this;&lt;/p&gt;
&lt;p&gt;CallWebServiceMethod(function(results) { self.OnComplete(results); });&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2210786" width="1" height="1"&gt;</description></item></channel></rss>