Select2-过滤特殊字符 [英] Select2 - filtering special characters
本文介绍了Select2-过滤特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对select2插件有问题.当我使用过滤器并键入mąka"时,它将找到带有mąka"和"maka"两个词的所有选项.是否可以自定义此脚本以仅找到mąka"一词?
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?
对不起,我的英语; p
Sorry for my english ;p
谢谢!
推荐答案
从select2网站 https: //select2.github.io/examples.html#matcher
From select2 site https://select2.github.io/examples.html#matcher
小提琴: 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)
})
});
这篇关于Select2-过滤特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文