0.0.2 • Published 11 years ago
jquery-pluginconfig v0.0.2
jquery-pluginconfig
Installation
You can install with npm
$ npm install jquery-pluginconfigWith Bower
bower install jquery-pluginconfigOr use some of the files at dist folder.
Usage
Let's say you have a jQuery plugin called my-awesome-plugin. And you want to allow the user to set the configs of that plugin for a given element using data-* attributes.
You can let them do this:
<div class="my-element" data-my-awesome-plugin-config="hello" data-my-awesome-plugin-config-two="world"></div>div>And then you can do this:
var config = $('.my-element').pluginConfig('my-awesome-plugin');
// You'll get { config: "hello", configTwo: "world"}
// Then use it
$('.my-element').myAwesomePlugin(config);You can also use it internally of your plugin, so the user won't have to call pluginConfig every time.
That's all, folks!