P
Peter Michaux
[snip]
// In a seperate file define the wrapper function
// which automatically wraps the serializeFormUrlencoded
// function.
if (typeof serializeFormUrlencoded != 'undefined') {
serializeFormUrlencoded = (function() {
var original = serializeFormUrlencoded;
return function(f, options) {
var extras = [];
if (options && options.extras) {
var oes = options.extras;
for (var i=0, ilen=oes.length; i<ilen; i++) {
extras[extras.length] = urlencode(oes.key) +
'=' +
urlencode(oes.value);
}
}
var result = original.apply(this, arguments);
Why not just call original(f)?
If multiple wrappers are used (as they are in the Ajax code I'm
working on) then inner wrappers may depend on other properties of the
options object.
Okay, change that to original(f, options).
I don't know why I fell into the pattern of using apply or call for
this. I used it all through the wrappers of my Ajax code I've been
playing with recently. There must have been a really great reason at
some point
I believe you are right and that original(f, options) is better.
Peter