Provides combobox as a Twitter Bootstrap component, based on dropdown (which is compatible down to IE7).
npm install bootstrap-comboboxProvides combobox as a Twitter Bootstrap component, based on dropdown (which is compatible down to IE7).
See demo.
Files of this component can be download from the source repository: js/
> It requires jQuery 1.10+ & Twitter Bootstrap 3+.
It's also available as a NPM package: npm install bootstrap-combobox
Combobox plugin can be applied on select elements, to turn them into comboboxes.
``html
class="optional overall classes"
data-btn-class="option toggle classes">
`
.btComboBox('selectedOption')
Returns selected option ([val, label, element]) or null (if none).
`javascript`
var o = $('.btn-group').btComboBox('selectedOption');
var val = o[0], label = o[1], elem = o[2];
.btComboBox('value')
Returns value of selected option.
`javascript`
var v = $('.btn-group').btComboBox('value')
.btComboBox({'action':"select",'value':"V"})
Selects option matching given value (if one).
`javascript`
$('.btn-group).btComboBox({'action':"select",'value':"value_to_select"})
.btComboBox('clear')
Removes all options and unselect value.
`javascript`
$('.btn-group').btComboBox('clear')
.btComboBox({'action':"load", parameters})
Appends options, using given parameters properties.
* pairs: Array of option to be appended; Each array element [val,label]
should be either , or anything else if next extractor ['_',null]
property is provided. If pair is it will be a divider.extractor
* (optional, required if elements of pairs array [val,label]
aren't ): Function (element of pairs) => [value, label].
`javascript
$('.btn-group').btComboBox({
'action':"load",
'pairs': [["val1", "label1"], ["val2", "label2"]]
});
// OR
$('.btn-group').btComboBox({
'action':"load",
'pairs': [{v:"val1", l:"label1"}, {v:"val2", l:"label2"}],
'extractor': function(o) { return [o.v, o.l] }
})
`
.btComboBox({'action':"reset", parameters})
Reset options, using same parameters as load method.
Keep value selection (if value is still available in new options).
.btComboBox('values')
Returns values from all available options.
`javascript`
var vs = $('.btn-group').btComboBox('values')
.btComboBox('disable') / .btComboBox('enable')
Disable/enable combobox.
`javascript`
$('.btn-group').btComboBox('disable');
$('.btn-group').btComboBox('enable');
change
Fired when combobox value is changed.
`javascript``
$("#combobox").on('change', function() { / ... / })