Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_findCallback unexpectedly dropping options when moving to custom function #39

Open
twolfson opened this issue Jan 22, 2015 · 0 comments

Comments

@twolfson
Copy link

I wanted to add a wrapper around the $.ajax invocation via a custom method. However, as soon as I switch to my custom wrapper, then I lose the callbacks.save.options I was previously setting. After debugging, it looks like that is intentional behavior in _findCallback. Can we please make it consistently inherit options? I don't see why they need to be dropped.

var _findCallback = function(callback, callbacks) {
var cb = { options: {} }, callbackType = typeof callback;
if (callbackType === "function") {
// Custom function with no options
cb.method = callback;
} else if (callbackType === "string" && callbacks[callback]) {
// Built in method, use default options
cb.method = callbacks[callback].method;
} else if (callbackType === "object") {
callbackType = typeof callback.method;
if (callbackType === "function") {
// Custom function
cb.method = callback.method;
} else if (callbackType === "string" && callbacks[callback.method]) {
// Built in method
cb.method = callbacks[callback.method].method;
cb.options = $.extend(true, cb.options, callbacks[callback.method].options, callback.options);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant