Sigh....didn't finish editing the code. Changed the this.ajaxFetched call to my 
functor ...functor.

Same way to do the same thing, but uglier.


var curThis = this;
var functor = function(arg1, arg2){curThis.ajaxFetched(arg1, arg2)}
var myAjax= new Ajax.Request(
url,
        {
method: 'get',
parameters: pars,
onComplete: functor
        }
);


Just be careful not to change curThis and arg1/arg2 if they are variables. When 
the function is called they will have the value of their last known state 
before the creating function ends (binding uhh quirks).

By the same token you can also specify static information this way.

var curThis = this;
var functor = function(arg1, arg2){curThis.ajaxFetched(arg1, arg2, 
'staticData')}
var myAjax= new Ajax.Request(
url,
        {
method: 'get',
parameters: pars,
onComplete: functor
        }
);


-Andrew Martinez

 -----Original Message-----
From:   [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]  On Behalf Of Martinez, 
Andrew
Sent:   Thursday, May 25, 2006 9:13 AM
To:     rails-spinoffs@lists.rubyonrails.org
Subject:        RE: [Rails-spinoffs] functions calling functions

Same way to do the same thing, but uglier.
var curThis = this;
var functor = function(arg1, arg2){curThis.ajaxFetched(arg1, arg2)}
var myAjax= new Ajax.Request(
url,
        {
method: 'get',
parameters: pars,
onComplete: this.ajaxFetched
        }
);


Just be careful not to change curThis and arg1/arg2 if they are variables. When 
the function is called they will have the value of their last known state 
before the creating function ends (binding uhh quirks).

By the same token you can also specify static information this way.

var curThis = this;
var functor = function(arg1, arg2){curThis.ajaxFetched(arg1, arg2, 
'staticData')}
var myAjax= new Ajax.Request(
url,
        {
method: 'get',
parameters: pars,
onComplete: this.ajaxFetched
        }
);



-Andrew Martinez

 -----Original Message-----
From:   [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]  On Behalf Of Jeremy Kitchen
Sent:   Thursday, May 25, 2006 3:25 AM
To:     rails-spinoffs@lists.rubyonrails.org
Subject:        Re: [Rails-spinoffs] functions calling functions

 << File: ATT1071742.dat >> << File: ATT1071743.txt >> On Wednesday 24 May 2006 
23:02, Maninder, Singh wrote:
> Ryan,
>
> What's the non prototyp-ish way to handle this?
>
> What if we don't want to use bind()?

it really depends.  If the "this.function2" function doesn't rely on state 
within the object, just turn it into a 'class method' and call it directly.  
If it does, then you'll have to use bind.

bind is really just a fancy wrapper around apply(), so you can do it manually, 
but I find bind to be much more handy :)

-Jeremy
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to