https://github.com/katt/jquery.disableinputs
Tiny jQuery plugin to toggle disabled on all of an element's controls.
https://github.com/katt/jquery.disableinputs
Last synced: 3 months ago
JSON representation
Tiny jQuery plugin to toggle disabled on all of an element's controls.
- Host: GitHub
- URL: https://github.com/katt/jquery.disableinputs
- Owner: KATT
- Created: 2014-05-23T12:10:56.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-04T10:28:49.000Z (about 12 years ago)
- Last Synced: 2024-10-11T11:35:06.114Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 215 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jquery.disableInputs
Small jQuery plugin to toggle `disabled` on all of a element's controls (`input`/`textarea`/`select`/`button`).
Useful when processing an AJAX submission on a form.
## Usage example:
```js
$('.my-ajax-form').on('submit', function(e) {
e.preventDefault();
var $this = $(this);
// disable form's inputs after serialising (otherwise you won't get the values)
var data = $this.serialize();
$this.disableInputs(true);
$.ajax({
url: $this.attr('action'),
type: 'post',
dataType: 'json',
data: data,
success: function(data) {
// do something
},
complete: function() {
// reset the form's inputs to the state they were before
$this.disableInputs(false);
}
});
});
```
## License
MIT