|
| 1 | +# jQuery selectBox: A styleable replacement for SELECT elements |
| 2 | + |
| 3 | +_Copyright 2011 Cory LaViska for A Beautiful Site, LLC. (http://abeautifulsite.net/)_ |
| 4 | + |
| 5 | +_Dual licensed under the MIT / GPLv2 licenses_ |
| 6 | + |
| 7 | + |
| 8 | +## Demo |
| 9 | + |
| 10 | +http://labs.abeautifulsite.dev/jquery-selectBox/ |
| 11 | + |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +* Supports OPTGROUPS |
| 16 | +* Supports standard dropdown controls |
| 17 | +* Supports multi-select controls (i.e. multiple="multiple") |
| 18 | +* Supports inline controls (i.e. size="5") |
| 19 | +* Fully accessible via keyboard |
| 20 | +* Shift + click (or shift + enter) to select a range of options in multi-select controls |
| 21 | +* Type to search when the control has focus |
| 22 | +* Auto-height based on the size attribute (to use, omit the height property in your CSS!) |
| 23 | +* Tested in IE7-IE9, Firefox 3-4, recent WebKit browsers, and Opera |
| 24 | + |
| 25 | + |
| 26 | +## License |
| 27 | + |
| 28 | +Licensed under both the MIT license and the GNU GPLv2 (same as jQuery: http://jquery.org/license) |
| 29 | + |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +Link to the JS file: |
| 34 | + |
| 35 | + <script src="jquery.selectbox.min.js" type="text/javascript"></script> |
| 36 | + |
| 37 | +Add the CSS file (or append contents to your own stylesheet): |
| 38 | + |
| 39 | + <link href="jquery.selectbox.min.css" rel="stylesheet" type="text/css" /> |
| 40 | + |
| 41 | +To create: |
| 42 | + |
| 43 | + $("SELECT").selectBox([settings]); |
| 44 | + |
| 45 | + |
| 46 | +## Settings |
| 47 | + |
| 48 | +To specify settings, use this syntax: |
| 49 | + |
| 50 | + $("SELECT").selectBox('settings', { settingName: value, ... }); |
| 51 | + |
| 52 | +### Available settings |
| 53 | + |
| 54 | +* __menuTransition__ _[default,slide,fade]_ - the show/hide transition for dropdown menus |
| 55 | +* __menuSpeed__ _[slow,normal,fast]_ - the show/hide transition speed |
| 56 | +* __loopOptions__ _[boolean]_ - flag to allow arrow keys to loop through options |
| 57 | + |
| 58 | + |
| 59 | +## Methods |
| 60 | + |
| 61 | +To call a method use this syntax: |
| 62 | + |
| 63 | + $("SELECT").selectBox('methodName', [options]); |
| 64 | + |
| 65 | +### Available methods |
| 66 | + |
| 67 | +* __create__ - Creates the control (default) |
| 68 | +* __destroy__ - Destroys the selectBox control and reverts back to the original form control |
| 69 | +* __disable__ - Disables the control (i.e. disabled="disabled") |
| 70 | +* __enable__ - Enables the control |
| 71 | +* __value__ - if passed with a value, sets the control to that value; otherwise returns the current value |
| 72 | +* __options__ - pass in either a string of HTML or a JSON object to replace the existing options |
| 73 | +* __control__ - returns the selectBox control element (an anchor tag) for working with directly |
| 74 | +* __refresh__ - updates the selectBox control's options based on the original controls options |
| 75 | + |
| 76 | + |
| 77 | +## Events |
| 78 | + |
| 79 | +Events are fired on the original select element. You can bind events like this: |
| 80 | + |
| 81 | + $("SELECT").selectBox().change( function() { alert( $(this).val() ); } ); |
| 82 | + |
| 83 | +### Available events |
| 84 | + |
| 85 | +__focus__ - Fired when the control gains focus |
| 86 | +__blur__ - Fired when the control loses focus |
| 87 | +__change__ - Fired when the value of a control changes |
| 88 | + |
| 89 | + |
| 90 | +### Known Issues |
| 91 | + |
| 92 | +* The blur and focus callbacks are not very reliable in IE7. The change callback works fine. |
0 commit comments