Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firstandthird/data-attrs
jQuery Plugin for data attributes
https://github.com/firstandthird/data-attrs
Last synced: 3 days ago
JSON representation
jQuery Plugin for data attributes
- Host: GitHub
- URL: https://github.com/firstandthird/data-attrs
- Owner: firstandthird
- Created: 2014-07-26T16:58:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-12-23T17:29:34.000Z (about 8 years ago)
- Last Synced: 2025-01-10T12:17:19.780Z (12 days ago)
- Language: JavaScript
- Size: 29.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Data Attrs
A set of utility plugins to deal with data attributes. Data attributes are great when you want to separate your javascript completely from IDs and classes.
## Install
`bower install data-attrs --save`
## Utilities
### $.named
`$.named('element')` will search for `
`### $.action
`$.action('delete', handler)` will get called when `Delete` is clicked.
If it will also pass back values, so if you had `Approve` you could have something like this:
```
$.action('approve', function(e, values) {
//this is the a tag that was clicked
//e is the click event
//values is an object that looks like { id: '123' }
});
```#### Scoped Actions
`$.action('delete', el, handler)` will get called when `Delete` is clicked inside `el`.
### $.module
`$.module('name', function(el, values, els) {});` callback will only get called if the `data-module="name"` exists.
It will also pass back any values and named elements. For example:
```html
Title
Content
```The callback will be called with:
`callback(el, { value: '123' }, { title: titleEl });`
### Declaritive Plugins
Declaritive Plugins will automatically bind elements to jQuery plugins.
With something like this:
```
```It will automatically call this behind the scenes:
```
$(el).slider({ pages: 3 });
```