You want to use either function#call() or function#apply....
Definitions (from https://developer.mozilla.org/)
function#call():
Calls a function with a given *this *value and *arguments * provided
individually.
$('aDiv').morph('background:#00ff00; width:300px;', {
afterFinish:callExample.call(this, 'aString')
});
function callExample(szStr){
console.log(szStr);
}
function#apply()
Calls a function with a given *this *value and *arguments *provided as an
array
$('aDiv').morph('background:#00ff00; width:300px;', {
afterFinish:applyExample.apply(this, ['aString', 'test'])
});
function applyExample(){
console.log(arguments);
}
Or Prototype's Function#bind()
$('aDiv').morph('background:#00ff00; width:300px;', {
afterFinish: bindExample.bind(this, 'aString')
});
function bindExample(){
console.log(arguments);
}
I noticed you're alert()'ing your debugging output... i would recommend
using FireBug.
Rick
On Wed, Sep 9, 2009 at 1:45 PM, mau <[email protected]> wrote:
>
> Hi everybody!
>
> I was wandering if anyone knows how to pass custom parameter to an
> effect callback function, I've tried something like this, but it's
> strange the behavior, works the first time, and then stops.
>
> $('aDiv').effect({afterFinish:changeSomething('aString'});
>
>
> function changeSomethin(szStr){
>
> alert(szStr);
> }
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---