v1.14.0-beta
Pre-release
Pre-release
To install: npm install bootstrap-select@next
.
The highlight of this release is support for using Ajax/JSON as the data source. This includes a new source
option, which supports 3 properties: data
, load
, and search
. All 3 support a function that passes an array of options to the callback argument. Alternatively, an array can be set (probably more useful for data
). If source.load
is set, it will be called when reaching the bottom of the dropdown menu. If source.search
is set, bootstrap-select's internal search functionality will be bypassed, allowing you to perform the search yourself. If performing a search and source.search
is set, it will be called again when reaching the bottom of the dropdown menu.
Example usage:
$('#test2').selectpicker({
source: {
data: function (callback) {
var array = [
{
text: 'Tent',
icon: 'fa-camera'
},
{
text: 'Flashlight',
selected: true
},
{
text: 'Disabled Option',
disabled: true
},
{
value: 'divider',
divider: true
},
{
text: 'Toilet Paper'
}
];
callback(array);
},
load: function (callback, page) {
$.ajax('/api/load-more', { data: { page } })
.then((response) => callback(response.data))
},
search: function (callback, page, searchTerm) {
$.ajax('/api/search', { data: { page, search: searchTerm } })
.then((response) => callback(response.data))
}
}
});
New Features
- #899: Ajax/JSON data source support
- #1315: Reset select element when
form.reset()
is called - #1416, #2147: Using
title
to set the select's placeholder has been deprecated. Useplaceholder
instead.title
will no longer set the placeholder starting in v2.0.0.title
andplaceholder
can still be used together to support a placeholder and a custom title. - #1449: Add
allowClear
option to support deselecting the value for single selects - #1893: Add
open
andclose
methods - #2042: Support assigning a function to
liveSearchStyle
for custom filtering
Bug Fixes
- #2507: Placeholder doesn't work when the first option is disabled