Is there a way to change the defaults within a plugin after they have been set. For example.
var defaults = {
imageWidth : w,
imageHeight : h
};
Later in the code I want to change the imageWidth value again.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Maybe, depends on the plugin. If it looks like this:
Then you’re out of luck. However, quite a few plugins publish their defaults as:
Where
pluginis the plugin name. If the defaults are publicly accessible like that (or if you want to hack the plugin to make them public), then you can change the defaults whenever you want. Of course, the new defaults won’t apply to existing instances.If this your own plugin then I think your architecture is a bit off. The “full screen” versus “specified width and height” configuration should be an option for the plugin and leave the default as something sensible (where “sensible” is, as always, context dependent). Then you’d just say this:
You could also use the
$.fn.plugin.defaultstrick to allow the sensible defaults to be changed as needed.