- From: Johnny Stenback <jst@netscape.com>
- Date: Thu, 14 Jun 2001 22:03:41 -0700
- To: Dylan Schiemann <dylans@yahoo.com>
- CC: David Flanagan <david@oreilly.com>, www-dom@w3.org
Dylan Schiemann wrote: > --- Johnny Stenback <jst@netscape.com> wrote: > >> >>David Flanagan wrote: >> [...] >> >>>As a trivial example, I ought to be able to write >>> >>code like this: >> >>> element.addEventListener("click", >>> { >>> message: "Hello world", >>> handleEvent: function(e) { >>> >>alert(this.message); } >> >>> }, >>> false); >>> >>>Anyone have thoughts about this? >>> >>> >> >>For the record, this already works in recent >>versions of mozilla (and >>Netscape 6.1 beta). >> >> > > Yes, it actually does. Though something like: > > function EventCaptureClass() > { > > } > > function addEventListeners(element) > { > element.addEventListener("click",this.singleClick,false); > } > > EventCaptureClass.prototype.addEventListeners = > addEventListeners; > > function singleClick(e) > { > alert(this); // this = element, not the instance of > the singleClick method. > } > Are you saying that the 'this' should be the function foo in the following case too? function foo(e) { alert(this); } element.addEventListener("click", foo, false); > EventCaptureClass.prototype.singleClick = singleClick; > > would be greatly served by David's suggestion. > > -Dylan Schiemann > http://www.sitepen.com/ > http://www.dylanschiemann.com > > > __________________________________________________ > Do You Yahoo!? > Spot the hottest trends in music, movies, and more. > http://buzz.yahoo.com/ > -- jst
Received on Friday, 15 June 2001 01:44:42 UTC