[Prototype-core] Event.observe to pass additional arguments to callback

2008-01-16 Thread Simon Thomas
I've been playing with the Event.observe function as i need it to pass extra arguments to my callback function and keeping 'this' in the scope of the callback function Object. I don't know if theres a better way to do this but thought i would share it here. observe: function(){ var args =

[Prototype-core] Re: Event.observe to pass additional arguments to callback

2008-01-16 Thread Matt Pennig
> Any thoughts?? I didn't test this, so it's based on assumption – but couldn't you accomplish the same thing by using callBackFunc.bindAsEventListener (callBackFunc, extraArg1, extraArg2)? I would imagine that would retain the proper 'this' reference. -Matt Pennig --~--~-~--~~-

[Prototype-core] Re: Event.observe to pass additional arguments to callback

2008-01-16 Thread kangax
Function#bind already accepts any number of arguments, where first one is used as a scope object and the rest are plugged directly into a binded function. $('myElment').observe('click', callbackFunc.bind(anyObj, extraArg1, extraArg2)); // => when clicked will invoke: callbackFunc(extraArg1, extr

[Prototype-core] Re: Event.observe to pass additional arguments to callback

2008-01-16 Thread Christophe Porteneuve
It doesn't even seem like the original need cares for binding, so how about: $(element).observe('eventName', func.curry(arg1, arg2...)); ? -- Christophe Porteneuve aka TDD [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscri

[Prototype-core] Re: Event.observe to pass additional arguments to callback

2008-01-16 Thread Simon Thomas
Ye not bothered about binding but the curry method works (except it puts the MouseEvent last) I've always worked to the convention that if an event is sent to a function it is the first argument. So i've created an 'args' function instead that does the same as curry but returns the reverse : retu

[Prototype-core] Re: Event.observe to pass additional arguments to callback

2008-01-16 Thread Tobias
This has already been suggested as Function#rcurry http://dev.rubyonrails.org/ticket/9034 - Tobias On 16 Jan., 23:23, Simon Thomas <[EMAIL PROTECTED]> wrote: > Ye not bothered about binding but the curry method works (except it > puts the MouseEvent last) > I've always worked to the convention