问题
I have a problem with select2 plugin. When I use filter and type "mąka", it finds all the options with "mąka" and "maka" word. Is it possible to customize this script to find just the "mąka" word?
Preview here
Sorry for my english ;p
Thanks!
回答1:
From select2 site https://select2.github.io/examples.html#matcher
fiddle : https://jsfiddle.net/alaniex/c3Ls1uf3/1/
function matchStart (term, text) {
if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) {
return true;
}
return false;
}
$.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) {
$(".js-example-matcher-start").select2({
matcher: oldMatcher(matchStart)
})
});
来源:https://stackoverflow.com/questions/43000164/select2-filtering-special-characters