diff --git a/docs/docs/options.md b/docs/docs/options.md
index 97d2df0ba..d1b98b09d 100644
--- a/docs/docs/options.md
+++ b/docs/docs/options.md
@@ -189,6 +189,14 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
The text displayed when a search doesn't return any results.
+
+ searchSubtext |
+ boolean |
+ true |
+
+ When set to false , searching will ignore subtext. When set to true searching will include subtext.
+ |
+
selectAllText |
string |
diff --git a/js/bootstrap-select.js b/js/bootstrap-select.js
index 7055df413..ea17b4dfb 100644
--- a/js/bootstrap-select.js
+++ b/js/bootstrap-select.js
@@ -393,7 +393,7 @@
};
//
- function stringSearch (li, searchString, method, normalize) {
+ function stringSearch (li, searchString, method, normalize, searchSubtext) {
var stringTypes = [
'display',
'subtext',
@@ -401,6 +401,10 @@
],
searchSuccess = false;
+ if (!searchSubtext) {
+ stringTypes.splice(1, 1);
+ }
+
for (var i = 0; i < stringTypes.length; i++) {
var stringType = stringTypes[i],
string = li[stringType];
@@ -971,6 +975,7 @@
liveSearchPlaceholder: null,
liveSearchNormalize: false,
liveSearchStyle: 'contains',
+ searchSubtext: true,
actionsBox: false,
iconBase: classNames.ICONBASE,
tickIcon: classNames.TICKICON,
@@ -2982,7 +2987,7 @@
var li = that.selectpicker.main.data[i];
if (!cache[i]) {
- cache[i] = stringSearch(li, q, searchStyle, normalizeSearch);
+ cache[i] = stringSearch(li, q, searchStyle, normalizeSearch, that.options.searchSubtext);
}
if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) {
@@ -3306,7 +3311,7 @@
var li = that.selectpicker.current.data[i],
hasMatch;
- hasMatch = stringSearch(li, keyHistory, 'startsWith', true);
+ hasMatch = stringSearch(li, keyHistory, 'startsWith', true, that.options.searchSubtext);
if (hasMatch && that.selectpicker.view.canHighlight[i]) {
matches.push(li.element);