Bind variables to callbacks

Bind variables to callbacks


I notice that the current API - any callback is generally the last
function in the arguments.
It would be a useful extension to be able to pass in further variables
to be passed in as arguments to this function. This would be similar
to how window.setTimeout works and is a very useful feature.
window.setTimeout(function(arg1,arg2,arg3) {
}, timeout, arg1, arg2, arg3 )
Without this you must rely on global variables or setting properties
on the element. I recently posted an example of where this was
difficult:
var z = 1
$(el).animate( css, speed, function() {
alert(z)
})
z = 100;
This will alert 100 as the z cannot be bound.
I proprose something along the lines of window.setTimeout
$(el).animate( css, speed, function(my_z) {
alert(my_z)
}, z)
or in general
$(el).generalfunction(arg1,arg2, callback , callback_arg1,
callback_arg2 ... )
My understanding of the inner workings of jQuery is not very strong,
so there maybe some other reason why this is not feasible/workable etc
and it would probably be a major change to jQuery core. Whether it is
worth the effort is debatable, but I think it would be extremely
useful - I have come up against this issue many times over the past
year.
(secretly hoping there's an easy/better way round this...)