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

Exposing defaults as a property of $.fn.pluginName #8

Closed
wheresrhys opened this issue Jan 12, 2012 · 2 comments
Closed

Exposing defaults as a property of $.fn.pluginName #8

wheresrhys opened this issue Jan 12, 2012 · 2 comments

Comments

@wheresrhys
Copy link

I was about to apply your basic plugin boilerplate to my plugins as I think in general it's neater than what I've been doing, but there is one thing I don't like; namely that the defaults are not exposed publically so that a developer can change the default settings for the plugin (eg if a plugin defaults to autoplay: false, but on the developer's site most instances use autoplay:true it makes sense for them to over-ride the default globally). Of course, the developer coudl go in and directly edit the plugin, but I never like doing this as it's not obvious to future developers that they can't just overwrite the plugin with updated versions from the plutgin's author.

I think this would need to be done by getting rid of the defaults variable and using $.fn[pluginName].defaults instead.

@addyosmani
Copy link
Member

@wheresrhys The repo actually has another pattern called the 'best options' pattern which tries to solve the problem you've described above. The reason I guess I kept it separate was so that developers wishing to use that pattern could easily modify the basic boilerplate accordingly, but it would be interesting to see if others feel the basic should cover this too. I don't mind at all dropping patterns if they end up being integrated with the base/basic if that's the case.

@yckart
Copy link
Contributor

yckart commented Jan 28, 2013

What about an extra chapter in the wiki about "how to handle the plugin defaults and predefinitions". According to this problem, extending the plugin defaults object with the options-parameter in our plugin-wrapper if !(this instanceof $), provides the most simple way to accomplish this problem.

Update: https://github.com/jquery-boilerplate/boilerplate/wiki/Handling-plugin-defaults-and-predefinitions

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

3 participants