Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sshaw/jquery-selectunique
Given a group of select fields with the same options, SelectUnique will remove an option from the other select fields when it's selected, and put it back when it's changed.
https://github.com/sshaw/jquery-selectunique
form javascript jquery jquery-selectunique select
Last synced: 16 days ago
JSON representation
Given a group of select fields with the same options, SelectUnique will remove an option from the other select fields when it's selected, and put it back when it's changed.
- Host: GitHub
- URL: https://github.com/sshaw/jquery-selectunique
- Owner: sshaw
- Created: 2013-02-05T04:39:39.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-27T03:41:10.000Z (over 11 years ago)
- Last Synced: 2024-10-10T18:53:50.148Z (about 1 month ago)
- Topics: form, javascript, jquery, jquery-selectunique, select
- Language: JavaScript
- Homepage: http://sshaw.github.com/jquery-selectunique
- Size: 195 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes.md
Awesome Lists containing this project
README
# jQuery SelectUnique Plugin
Given a group of select fields with the same options, SelectUnique will remove an option from the other select fields when it's selected, and put it back when it's changed.
[Demo](http://sshaw.github.com/jquery-selectunique#demo)
## Usage
$(selector).selectunique();
SelectUnique requires jQuery *1.7.1* or later. Options without text will be ignored.
### Options
#### `ignoreOption`
$(selector).selectunique({
ignoreOption: function(option) { return option.val() == 'ignore_me_buddy' }
});
Instruct the plugin to not manage the given option. The `option`
argument passed to the function is a jQuery object.### Methods
#### `refresh`
$(selector).selectunique('refresh');
Refresh the state of the select fields given by `selector`.
This is useful of you're adding and/or removing select fields via JavaScript.#### `remaining`
var opts = $(selector).selectunique('remaining');
$.each(opts, function() {
console.log('text: ' + this.text + ' value: ' + this.value);
});An array of remaing options. I.e., options still available for selecting. Returns an empty array if
no options are available. Each element is an `HTMLOptionElement`.#### `selected`
var opts = $(selector).selectunique('selected');
$.each(opts, function() {
console.log('text: ' + this.text + ' value: ' + this.value);
});An array of options that have been selected. Returns an empty array if
no options have been selected. Each element is an `HTMLOptionElement`.
While these nodes are currently selected, their `selected` property is `false`.