https://github.com/aduth/jquery.optgrouper
Automatically group <option>'s into <optgroup>'s using a custom data-optgroup attribute
https://github.com/aduth/jquery.optgrouper
Last synced: about 1 year ago
JSON representation
Automatically group <option>'s into <optgroup>'s using a custom data-optgroup attribute
- Host: GitHub
- URL: https://github.com/aduth/jquery.optgrouper
- Owner: aduth
- License: mit
- Created: 2013-01-22T03:21:48.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-01-15T00:58:50.000Z (over 12 years ago)
- Last Synced: 2025-03-13T22:35:06.600Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://aduth.github.com/jquery.optgrouper/
- Size: 352 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# jQuery Optgrouper
Optgrouper is a jQuery plugin which makes it easy to group related `` elements into `` groupings using a custom `data-optgroup` attribute.
[Demonstration](http://aduth.github.com/jquery.optgrouper/)
## Usage
Add `data-optgroup` attribute to each `` element.
```html
Cheetah
Lizard
Snake
Elephant
```
Include jquery.js and jquery.optgrouper.js, then call Optgrouper when page is ready.
```html
$(document).ready(function() {
$('#selAnimals').optgrouper();
});
```
## Options
There are currently two options to control the behavior of Optgrouper.
* `sortGroups` (Function) - Given an array of group names, return the same array in a custom sort order
* `renderImmediately` (Boolean) - Control whether groups are rendered immediately upon plugin call (defaults to true)
_Example_
```javascript
$('#selAnimals').optgrouper({
sortGroups: function(groups) {
return groups.sort();
},
renderImmediately: false
}).data('plugin_optgrouper').renderGroups();
```
## License
Copyright (c) 2014 Andrew Duthie
Released under the MIT License (see LICENSE.txt)