I have been using ember-select-2 package or to use select2 in ember but trying to use my own search but not working as expected matcher should use matchCuston function for search
index.hbs
{{select-2
content=fields
value=selectedField
placeholder=''
matcher=(action 'matchCustom')
}}
script.js
matchCustom(params, data) {
console.log("I am working and checking")
// If there are no search terms, return all of the 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) {
var modifiedData = $.extend({}, data, true);
modifiedData.text += ' (matched)';
// You can return modified objects from here
// This includes matching the `children` how you want in nested data sets
return modifiedData;
console.log("I am processing thingsss")
}
// Return `null` if the term should not be displayed
return null;
},
references used
https://select2.org/searching#customizing-how-results-are-matched