Thank you, Arieh.
Ant what about the arguments passed in apply ?

On 6 Sep., 14:12, אריה גלזר <[email protected]> wrote:
> I realy think you should read about call/apply/bind, and even better, read
> the mootools code, so you could see that bind already uses apply.
> anyway, this is what you are looking for:http://jsfiddle.net/TfhL8/4/
>
> and just to make it clear - the first argument to both apply and call
> specifies what this will point to. failing to specify this argument will
> result with only the global scope. But, if you already use bind, there is no
> reason using call, as the function was already binded. When you use bind,
> simply call the function itself:http://jsfiddle.net/TfhL8/3/
>
> hope this clarifies some of your confusion
>
> On Mon, Sep 6, 2010 at 2:45 PM, berlinsurfer 
> <[email protected]>wrote:
>
>
>
> > I found the solution: I had to use apply instead. See the jsfiddle:
> >http://jsfiddle.net/TfhL8/1/
> > Thanks,
> > Jan
>
> > On 6 Sep., 11:52, berlinsurfer <[email protected]> wrote:
> > > Thanks, Arieh,
> > > but that's not what I wanted to achieve. "This.previous" is referring
> > > to the old function "doSomething". To make it clearer:
> >http://jsfiddle.net/TfhL8/
>
> > > On 6 Sep., 11:42, אריה גלזר <[email protected]> wrote:
>
> > > > when using call, failing to pass a first argument, it will bind this to
> > the
> > > > null.
> > > > you don't need both bind and call. Also, you can simply call fn:
>
> > > >http://jsfiddle.net/4ZzLs/
>
> > > > On Mon, Sep 6, 2010 at 12:27 PM, berlinsurfer <
> > [email protected]>wrote:
>
> > > > > Hi,
> > > > > a short question: is there a possibility to store this.previous()
> > > > > (when refatoring a Class) within another function ?
> > > > > This throws an error:
> > > > > Request.HTML = Class.refactor(Request.HTML, {
> > > > > ...,
> > > > > onSomethingElse: function() {
> > > > > var fn = function () {this.previous()}.bind(this);
> > > > > fn.call();
> > > > > }
> > > > > });
>
> > > > > It says this.previous() is undefined. Why ? Even when logging "this"
> > > > > via console.log, this.previous is marked as undefined. When calling
> > it
> > > > > directly it works however. Very strange to me...
> > > > > Cheers,
> > > > > Jan
>
> > > > --
> > > > Arieh Glazer
> > > > אריה גלזר
> > > > 052-5348-561
> > > > 5561
>
> --
> Arieh Glazer
> אריה גלזר
> 052-5348-561
> 5561

Reply via email to