Currently, this plugin is built on top of jQuery 1.11/2 and uses Twitter Bootstrap 3.
<div id="chooser"></div>
Use the plugin as follows:
$('#chooser').chooser({
data: ['option 1', 'option 2', 'option 3']
});
Name | Type | Required? | Default | Description |
---|---|---|---|---|
placeholder |
string |
optional |
'Choose...' |
Placeholder text to show in the input |
labelClass |
string |
optional |
'info' |
Bootstrap label CSS class to apply to the tokens inside the input |
data |
array |
required |
[] |
Array of string tokens to be the options |
max |
number |
optional |
null |
Maximum number of selections allowed |
select |
function |
optional |
null |
Callback invoked after a selection is made |
Name | Args | Returns | Description |
---|---|---|---|
$().chooser('destroy') |
none |
undefined |
Destroys the plugin. Removes all references. |
$().chooser('selections') |
none |
array of selected strings |
Get the current list of selected tokens |
$().chooser('update', []) |
array of strings |
undefined |
Update the data list with a new list. Does clear the selected tokens. |
All the CSS that is needed is provided in the stylesheet. Copy to wherever you need it.
Reference the script file and the CSS stylesheet. Requires jQuery and Bootstrap. Bower installation coming soon.
- Add meaningful tests
- Create Bower package
This plugin is available under the MIT license.