Path: csiph.com!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1595535.oMNUckLgyt@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Fri, 25 May 2012 10:10:49 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 35 NNTP-Posting-Date: 25 May 2012 10:10:49 CEST NNTP-Posting-Host: 64792559.newsspool1.arcor-online.net X-Trace: DXC=\;6LLf@^e;E[kmHKHnaEnMic==]BZ:afN4Fo<]lROoRAnkgeX?EC@@@KPeR?^YhTLGDZm8W4\YJNLJ`:FmdeL>K@U@3`]Ai;BfB?4_4T;C2BBA X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:14147 Andrew Poulos wrote: > I have some code that "applies" a transformation to an element. Its > written in such a way that multiple transformations can be applied > simultaneously. > > One of the possible triggers includes the onclick event. This works fine > for one transformation: > > elem.onclick = function() { //transformation01... }; > > but for multiple transformations its creating: > > elem.onclick = function() { //transformation01... }; > elem.onclick = function() { //transformation02... }; > elem.onclick = function() { //transformation03... }; > ... > > How can I get subsequent functions to include the code from any previous > function? Use either elem.addEventListener() or closures if the former is unavailable. (Do not use elem.attachEvent(); execution order is not guaranteed then.) jsx.dom.addEventListener() does that for you: (please copy before use) PointedEars -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, (2004)