Re: handler has no properties

Justin Perkins
Wed, 30 Jan 2008 20:08:22 -0000

On Jan 30, 2008 1:46 PM, wte
<wyatt.eurich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> What am I not understanding?

In anonymous functions like that (you''re iterator), you need to bind
to the current instance of your object. So this:

>         initialize : function() {
>                 $$("span").each(function(item, index) {
>                         Event.observe(item, ''mousedown'',
this.onmousedown, false);
>                 });

Would become:

>         initialize : function() {
>                 $$("span").each(function(item, index) {
>                         Event.observe(item, ''mousedown'',
this.onmousedown.bindAsEventListener(this), false);
>                 }.bind(this));

-justin