https://github.com/bfontaine/togglable
jQuery plugin to toggle boolean values with AJAX.
https://github.com/bfontaine/togglable
ajax jquery
Last synced: about 1 year ago
JSON representation
jQuery plugin to toggle boolean values with AJAX.
- Host: GitHub
- URL: https://github.com/bfontaine/togglable
- Owner: bfontaine
- Created: 2013-03-05T22:24:50.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-03-06T15:14:14.000Z (about 13 years ago)
- Last Synced: 2025-03-23T23:43:42.249Z (about 1 year ago)
- Topics: ajax, jquery
- Language: JavaScript
- Size: 188 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Togglable
This jQuery plugin allows you to toggle boolean values (e.g. user settings)
using AJAX calls.
This is currently under developement.
## Usage
Add a `togglable` class and a `data-togglable-values` to enable Togglable on an
element, then call the `.togglable` method on its container:
```
$( '#the-container' ).togglable();
```
You can use multiple togglable elements in one container.
An URL must be given for each element. You can use the same URL for all, using:
```
$( '#the-container' ).togglable({ url: '/foo' });
```
…Or you can set a `data-togglable-url` on each element. Possible values should
be specified in a `data-togglable-values`. They can be comma-separated, or a
valid JSON array of objects. Each object must have a `label` and a `value`
properties, e.g.:
```html
```
### Example
```html
Yes or no?
```
```js
$( '#some-id' ).togglable({
url: '/api/1/yes-or-no/toggle'
});
```