1
0
mirror of synced 2025-03-10 14:46:10 +03:00

Improve matcher example (see #4668)

This commit is contained in:
alexweissman 2017-09-13 19:34:37 -04:00
parent d2655a89ba
commit b61b7f4892

View File

@ -21,7 +21,12 @@ function matchCustom(params, data) {
if ($.trim(params.term) === '') {
return data;
}
// Do not display the item if there is no 'text' property
if (typeof data.text === 'undefined') {
return null;
}
// `params.term` should be the term that is used for searching
// `data.text` is the text that is displayed for the data object
if (data.text.indexOf(params.term) > -1) {
@ -64,6 +69,11 @@ function matchStart(params, data) {
return data;
}
// Skip if there is no 'children' property
if (typeof data.children === 'undefined') {
return null;
}
// `data.children` contains the actual options that we are matching against
var filteredChildren = [];
$.each(data.children, function (idx, child) {