Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/elboletaire/data-attribute-parser

jQuery helper plugin to parse `data-` attributes and load other plugins using that parsed attributes as plugin params.
https://github.com/elboletaire/data-attribute-parser

html-data javascript jquery jquery-plugin parse-attributes plugin

Last synced: 17 days ago
JSON representation

jQuery helper plugin to parse `data-` attributes and load other plugins using that parsed attributes as plugin params.

Awesome Lists containing this project

README

        

data-attribute-parser
=====================

jQuery helper plugin to parse `data-` attributes and load other plugins using that parsed attributes as plugin params.

How to use it?
--------------

Here's an example on how to load ckeditor (it's an example!) on textarea
inputs. Assuming you have some textareas like the following:

```html

This textarea won't have CKEditor enabled

This textarea will have CKEditor enabled with the specified values

```
Now parse the params and load the plugin:

```javascript
$('textarea').parseDataAttributes({
prefix: "ckeditor", // will search for data-ckeditor- prefixed attributes
params: {
// default params to be merged with data- params
toolbar: "full",
resize_enabled: false
}
}, function($this, params) {
// Run a callback after params have been parsed
$this.ckeditor(params);
}
);
```
> WARNING: camelCasedValues are lowercased by the DOM, so you will need to
declare that attributes as dashed-attributes and they will be converted to
camel cased (i.e. `dashed-attributes` to `dashedAttributes`).