-
Notifications
You must be signed in to change notification settings - Fork 0
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
Foundation 7: JavaScript plugin initialization #13
base: master
Are you sure you want to change the base?
Conversation
I like the direction - the JS should be easy enough to mix with other JS plugins without conflict. Would a global option to prefix the data-attributes be the best option? |
I do think so, @rafibomb. While |
Maybe the default is no prefix, and you can configure one in your app if you need to. Wouldn't that help with backwards compatibility? |
(Ack! Sorry. Butterfingers closed the issue.) |
Thanks a lot for your participating guys. Note: In this case, I think we should not wait for v7, because that will be compatible with the current major version, anyway! |
Having a configuration file for those that build their custom Foundation with Gulp, etc. would be a good approach imo. I guess these configs could also be used/set in the $(document).foundation({
namespace: 'zf'
}); |
I only meant adding the prefix and its name, but the full solution that I mentioned in the proposal could be fully implemented in v7. Here is the full solution:
|
|
||
## Solution | ||
I would suggest these two steps to solve that: | ||
- Adding a namespace to the data attribute of the plugin name and the plugin’s options, so the data attributes should look like: `data-zf-plugin-name` and `data-zf-options`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wether in Sass, JS, HTML (ect...), everywhere we work on the global namespace, we can't declare names without prefixs. The probability of naming collisions are too high, and they are often incorrigible for the user.
So YES, we should use a Foundation namespace, thank you !
About data-
attributes :
JavaScript libraries may use the custom data attributes, as they are considered to be part of the page on which they are used. Authors of libraries that are reused by many authors are encouraged to include their name in the attribute names, to reduce the risk of clashes. Where it makes sense, library authors are also encouraged to make the exact name used in the attribute names customizable, so that libraries whose authors unknowingly picked the same name can be used on the same page, and so that multiple versions of a particular library can be used on the same page even when those versions are not mutually compatible. -- W3C
However, I think zf
is rare enough for we use it as prefix without risk of a naming collision.
## Solution | ||
I would suggest these two steps to solve that: | ||
- Adding a namespace to the data attribute of the plugin name and the plugin’s options, so the data attributes should look like: `data-zf-plugin-name` and `data-zf-options`. | ||
- Removing the previous data individual options, and keep all the passed options in `data-zf-options`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it makes difficult the change of an option through HTML ? If yes, we have to ensure that all options can be modified through Foundation.
in Js.
About the customizable namespace, I propose :
|
@zurb/yetinauts Could you please review this proposal.