Also note that you can use Function:delay or Function:periodical: this.btnsScroll.delay(20, this, 'down');
this.btnsScroll.periodical(20, this, 'down'); On Sat, Apr 30, 2011 at 1:11 PM, Arian Stolwijk <[email protected]> wrote: > You don't have to wrap that in a function. > > For example, use: (if you're using 1.2 or 1.2compat in 1.3, it might be > safer to use .pass, which is basically the same as .bind, but with swapped > arguments (first the arguments, and then the thisArg: fn.pass([arg1, arg2, > ...], thisArg); This is because the behavior changed a little when using > arguments with .bind to make it EcmaScript 5 compatible.) > > setInterval(this.BtnsScroll.bind(this, 'down'), 20); > > Using .pass: > > setInterval(this.BtnsScroll.pass('down', this), 20); > > Also with wrapping the context (this) changes and calling bind doesn't > execute the function, so you might want to use .call or .apply (native js > methods) > > setInterval(function(){ > this.btnsScroll.call(this, 'down'); > }.bind(this), 20); > > > > > On Sat, Apr 30, 2011 at 12:57 PM, hamburger <[email protected]> wrote: > >> may be just to understand the .bind right: >> what is the right binding for my example above. >> for me no one is working. >> Scroll: function(dir){ >> //this.btnsScrollTimer = setInterval(function () >> {this.BtnsScroll("down").bind(this)}, 20); //wrong >> //this.btnsScrollTimer = setInterval(function () >> {this.BtnsScroll("down")}, 20).bind(this); //wrong >> }, >> >> . > > >
