FYI. Another solution without using ".bind()" would be to assign "this" to a
local variable.

var myMenueScroll = new Class({
    ...
    initialize : function(element, options ) {
        ...
        var that = this;

        this.scrollDownBtn.addEvents({
            click: function(e) {
                e.preventDefault();
                // "that" has access to the scope that "bark()" is in
                that.bark();
            }
        });
    },
    ...
});


Hope this gives you another way to think about it. Happy coding.

~Philip

http://www.lonestarlightandsound.com/


On Wed, Apr 27, 2011 at 2:25 PM, hamburger <[email protected]> wrote:

> ohh thanks:
> i did this:
>        this.scrollDownBtn.addEvents({
>            mouseup: function(e){
>                console.log("testthis: ",this);
>            },
>            mousedown: function(e){
>               console.log("test: ",boxHeight);
>               this.bark();
>            }
>
>        }.bind(this));
>
>
> On 27 Apr., 21:22, Paul Saukas <[email protected]> wrote:
> > http://jsfiddle.net/bwB6E/for an  in place visual :)
> >
> > On Wed, Apr 27, 2011 at 3:21 PM, Oskar Krawczyk <
> [email protected]>wrote:
> >
> > > function(){}.bind(this);
> >
> > > On Apr 27, 2011, at 9:19 PM, hamburger wrote:
> >
> > > > thy for the fast answers
> > > > any hint in jsfiddle how to bind?
> >
> > > > On 27 Apr., 21:15, Sanford Whiteman <[email protected]>
> > > > wrote:
> > > >>> this.bark is not a function  why not????
> >
> > > >> Because  `this`  is  the element unless you bind a different `this`
> --
> > > >> classic `this` situation....
> >
> > > >> -- S.
>

Reply via email to