0

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?

asked Jul 4, 2014 at 7:10

1 Answer 1

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!

answered Jul 4, 2014 at 17:46
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.