<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">That's a great fucking explanation. Thanks a bunch!<DIV>I feel I owe some sort of tip here ... but I can't really .. oh, wait :)</DIV><DIV>tip taken from <A href="http://www.dustindiaz.com/awkward-looking-javascript/">http://www.dustindiaz.com/awkward-looking-javascript/</A></DIV><DIV>Since javascript functions are mainly variables (sort of), you can have a function that calls itself on initalisation, like</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(function() {</DIV><DIV>do_stuff;</DIV><DIV>}());</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>this also works in json, so you can have immediately executing code returned from the server. This might not be good practice, but it sure shows how cool javascript is :)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>sorry everyone for the OT stuff, but if you read this thread,hopefully your interested in some javascript voodoo anyway.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Andreas</DIV><DIV><BR><DIV><DIV>On Jul 21, 2006, at 23:49 , thomas Aylott wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV><DIV>On Jul 21, 2006, at 4:47 PM, Andreas Wahlin wrote:</DIV><BLOCKQUOTE type="cite"><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV><SPAN class="Apple-style-span" style="color: rgb(0, 0, 221); ">If you use prototype, there's a modified version in there that adds </SPAN><B style="color: rgb(0, 0, 221); font-weight: bold; "><SPAN class="Apple-style-span" style="color: rgb(0, 0, 221); font-weight: bold; ">.bind(this)</SPAN></B><DIV style="color: rgb(0, 0, 221); "><BR class="khtml-block-placeholder"></DIV>*cough* slightly off topic. The .bind(this) just makes the this keyword accessibly in the function that you bind it to, right? Sort of like passing it in as an argument when you call the function.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Andreas</DIV></SPAN></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><FONT class="Apple-style-span" color="#000000" face="Monaco" size="2"><SPAN class="Apple-style-span" style="background-color: transparent; font-size: 10px;">.bind()</SPAN></FONT> replaces every use of "this" inside with a call to the object you put in the argument. Like so:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><I><DIV><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px; font-style: normal;">function(){</SPAN></FONT></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre"> </SPAN><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px; font-style: normal;">alert(this.thinggy);</SPAN></FONT></DIV><DIV><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px; font-style: normal;">}.bind({thinggy: 'Howdy!!!'})</SPAN></FONT></DIV><SPAN class="Apple-style-span" style="font-style: normal;"><DIV><BR class="khtml-block-placeholder"></DIV><BR></SPAN></I><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV style=""><FONT class="Apple-style-span" size="4"><SPAN class="Apple-style-span" style="font-size: 14px;"><SPAN class="Apple-style-span" style="font-size: 14px; "><SPAN class="Apple-style-span" style="font-size: 14px; ">thomas Aylott—</SPAN></SPAN></SPAN></FONT><B style="font-weight: bold; "><SPAN class="Apple-style-span" style="font-weight: bold; "><SPAN class="Apple-style-span" style="font-weight: bold; ">subtleGradient</SPAN></SPAN></B></DIV></SPAN><BR class="Apple-interchange-newline"></SPAN> </DIV><BR><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">______________________________________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">For new threads USE THIS: <A href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">(threading gets destroyed and the universe will collapse if you don't)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.macromates.com/mailman/listinfo/textmate">http://lists.macromates.com/mailman/listinfo/textmate</A></DIV> </BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>