jquery-plugin-components
v2.0.0
Published
Auto initialize your plugins via HTML data attributes
Downloads
8
Maintainers
Readme
jQuery Plugin as Components
Initialize your jQuery plugins via data attributes.
<div data-component="date-picker"></div>
<!-- is the same as -->
<div data-component="datePicker"></div>
This element will be initialized as a date-picker
jQuery plugin.
Install
Via bower:
bower install --save jquery-plugin-components
Via npm:
npm install --save jquery-plugin-components
Or get the minified file inside dist/index.min.js
.
Usage
Call the jQuery plugin startComponents
on any element, e.g.
<body>
<div data-component="date-picker" data-date="01/01/2016"
data-format="dd/MM/yyyy"></div>
<script src="vendor/date_picker.min.js"></script>
<script src="vendor/jquery-plugin-components.min.js"></script>
<script>
$('body').startComponents();
</script>
</body>
You can pass options by using any data-parameters
, as in the example above. Note that the data-date
and data-format
will be passed to datePicker
's plugin inside an object, like:
$('div').datePicker({date: '01/01/2016', format: 'dd/MM/yyyy'});
You can check an example inside example
folder.
Contributing
Install the dependencies with npm install
.
- Fork the repository;
- Create a branch and write your code;
- Open a pull request;
- Let's talk about!