W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: ECMAScript binding for EventListener

From: Johnny Stenback <jst@netscape.com>
Date: Thu, 14 Jun 2001 22:03:41 -0700
Message-ID: <3B29972D.3060008@netscape.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT