var v = "Some var";
var testReq = new Request.JSON({
url:"/test/",
onRequest:function(){
alert (this+'\n'+v)
}
}).send();
this shoud work.
pass binds the windows element to the function, if you dont specify the
second argument.
But as you can see you dont need pass or bind in this case... do you?
But ill talk to some ppl about this behavior.
--
Fábio Miranda Costa
Solucione Sistemas
Front-End Engineer
http://meiocodigo.com
On Sat, Jul 25, 2009 at 10:32 AM, Alexey A <[email protected]> wrote:
>
> I've got a simple request
>
> var v = "Some var";
> var testReq = new Request.JSON({
> url:"/test/",
> onRequest:function(v){alert (this+'\n'+v)}.pass(v)
> }).send();
>
> And it shows me:
>
> [object Window]
> Some var
>
> But, if I remove pass() I got
>
> [object Object]
> undefined
>
> And the Object here is my request object (instead of Window object
> with pass())
>
> Am I write that it's a strange behavior? Or maybe someone could
> explain me why it should be Window instead of Request associated with
> *this*?
>
> I've found only one solution: I've added onRequest like this:
>
> testReq.setOptions({onRequest : on_request.bind(testReq, v)})
>
> just before sending it.