Menu icon Foundation
F6-Sites Plugin global defaults

I am currently initializing all plugins via $(document).foundation(); in my app.js file and would like to set default, plugin-specific properties in the same file, not within the Defaults property of individual plugin JS files (in an attempt to keep those untouched for easier Foundation upgrades). This used to be an option in F5 - http://foundation.zurb.com/sites/docs/v/5.5.3/javascript.html#configuration

The only section I can find in the F6 docs talking about setting global properties is here - http://foundation.zurb.com/sites/docs/javascript.html#configuring-plugins - but it says to edit the plugin specific JS files. I'm pretty sure I am misunderstanding something, so any help is appreciated!

pluginsjavascript

I am currently initializing all plugins via $(document).foundation(); in my app.js file and would like to set default, plugin-specific properties in the same file, not within the Defaults property of individual plugin JS files (in an attempt to keep those untouched for easier Foundation upgrades). This used to be an option in F5 - http://foundation.zurb.com/sites/docs/v/5.5.3/javascript.html#configuration

The only section I can find in the F6 docs talking about setting global properties is here - http://foundation.zurb.com/sites/docs/javascript.html#configuring-plugins - but it says to edit the plugin specific JS files. I'm pretty sure I am misunderstanding something, so any help is appreciated!

This post has been closed. No new replies can be added.

Tommy McGahee almost 4 years ago

Any takers?

Brian Tan over 3 years ago

Set before init, example for Accordion.

Foundation.Accordion.defaults['slideSpeed'] = 250;

For Abide patterns,

Foundation.Abide.defaults['patterns']['dashes_only'] = /^[0-9-]*$/;

Tommy McGahee over 3 years ago

Thanks for the reply Brian! Our JS file, so far, is very simple, and we're initiating foundation with a single line:

 $(document).ready(function(){
  $(document).foundation();
});

Dumb question, but how should we structure that init and the parameter settings to work together?

I get a "Foundation is not defined" error when doing this:

$(document).foundation();
Foundation.Accordion.defaults['slideSpeed'] = 250; 

Brian Tan over 3 years ago

override the builtin defaults before foundation reflow. F6.1 has a double dip safeguard to prevent re-initialization of the same plugin.

Foundation.Accordion.defaults.slideSpeed = 250;
$(document).foundation();

Tommy McGahee over 3 years ago

Edit: Found it, resolving thread.

Thanks Brian, that did the trick. We are using CodeKit to generate and manage the F6 project, and it seems to be throwing some incorrect undefined errors, which is what was confusing me at first.

Thanks for the info too on the double dip safeguard!

Is there a function to mark posts as solved?

Thanks,
Tommy