Select2 - filtering special characters

橙三吉。 提交于 2019-12-24 04:23:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!