Reputation: 18291
If I understand correctly, the correct use of matcher before v4.0.0 was:
$('#myselect').select2({
...
matcher: function(term, text) {
// return true if matches, false if not
}
})
With 4.0.2 this doesn't work - AFAICT there is only one parameter to matcher
, which is an object. I could use the same function signature and wrap it on oldWrapper
, but I would like to avoid that... I was unable to find any example or docs. So, how do I use the new matcher? Or at least, what is the function signature?
Upvotes: 5
Views: 2351
Reputation: 18291
Found it: https://github.com/select2/select2/blob/master/src/js/select2/defaults.js (search for function matcher
).
Basically, the function signature is:
matcher: function (params, data) {
// should return:
// - null if no matches were found
// - `data` if data.text matches params.term
}
My problem however was connected to the fact that "text" is a hardcoded field name - I was of course using something else. Hope it helps someone.
Upvotes: 9