I have a jQuery plugin and I need to change it's default settings (and force these defaults settings for every instance of the plugin). Modifying its source code is not an option (updates etc), so I figured that if I proxy'd it, I would be home. So I looked up for an example, how you do that in JS:
var proxied = jQuery.ajax; // Preserving original function
jQuery.ajax = function() {
jQuery("#loading").dialog({modal: true});
return proxied.apply(this, arguments);
}
Now this code is quite straightforward, but
I'm not sure how can I proxy "element method", like $(".select").multiselect(); in similar fashion?
1 Answer 1
Okay, I searched a bit more and found the answer myself.
All jQuery object methods are "stored" in jQuery.fn object. So all I had to do was
var proxied = jQuery.fn.multiselect;
jQuery.fn.multiselect = function() {
// stuff
return proxied.apply(this, arguments);
};
Hope somebody finds that helpful!