|
@@ -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) {
|