mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
Add custom filter function
This commit is contained in:
@@ -447,6 +447,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback to filter the search result the label text.
|
||||||
|
* @type {Function}
|
||||||
|
* @param {Object || String} option
|
||||||
|
* @param {String} label
|
||||||
|
* @param {String} search
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
|
filterFunction: {
|
||||||
|
type: Function,
|
||||||
|
default(option, label, search) {
|
||||||
|
return label.toLowerCase().indexOf(search.toLowerCase()) > -1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional callback function that is called each time the selected
|
* An optional callback function that is called each time the selected
|
||||||
* value(s) change. When integrating with Vuex, use this callback to trigger
|
* value(s) change. When integrating with Vuex, use this callback to trigger
|
||||||
@@ -854,7 +869,7 @@
|
|||||||
if (typeof label === 'number') {
|
if (typeof label === 'number') {
|
||||||
label = label.toString()
|
label = label.toString()
|
||||||
}
|
}
|
||||||
return label.toLowerCase().indexOf(this.search.toLowerCase()) > -1
|
return this.filterFunction(option, label, this.search)
|
||||||
})
|
})
|
||||||
if (this.taggable && this.search.length && !this.optionExists(this.search)) {
|
if (this.taggable && this.search.length && !this.optionExists(this.search)) {
|
||||||
options.unshift(this.search)
|
options.unshift(this.search)
|
||||||
|
|||||||
Reference in New Issue
Block a user