Re: handler has no properties

wte
Wed, 30 Jan 2008 20:29:36 -0000

Thank-you so much, I had tried the bindAsEventListener before and just
got different errors.
I did not catch that I needed to bind the iterator.

Works great now.



On Jan 30, 3:08 pm, "Justin Perkins"
<justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On Jan 30, 2008 1:46 PM, wte
<wyatt.eur...-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