Skip to content

brunoskonrad/jquery-plugin-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Plugin as Components

npm version Bower version

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.

  1. Fork the repository;
  2. Create a branch and write your code;
  3. Open a pull request;
  4. Let's talk about!

About

Auto initialize your plugins via HTML data attributes

Resources

License

Stars

Watchers

Forks

Packages

No packages published