Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bfontaine/togglable

jQuery plugin to toggle boolean values with AJAX.
https://github.com/bfontaine/togglable

ajax jquery

Last synced: 22 days ago
JSON representation

jQuery plugin to toggle boolean values with AJAX.

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'
});
```