thx Phillip,
that is a very useful hint.
i used it and it works.
is there any place to read more about it, because I do not understand
why it is working.
Scroll: function(dir){
var that = this;
if(dir=="down"){
this.btnsScrollTimer = setInterval(function ()
{that.BtnsScroll("down")}, 20); //works
//this.btnsScrollTimer = setInterval(function ()
{this.BtnsScroll("down").bind(this)}, 20); //wrong
//this.btnsScrollTimer = setInterval(function ()
{this.BtnsScroll("down")}, 20).bind(this); //wrong
} else {
this.btnsScrollTimer = setInterval(function ()
{that.BtnsScroll("up")}, 20);
}
},
On 28 Apr., 22:57, Philip Thompson <[email protected]> wrote:
> 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/foran 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.