关于 jquery select2 多个关键字 模糊查询的解决方法
生活随笔
收集整理的這篇文章主要介紹了
关于 jquery select2 多个关键字 模糊查询的解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
select2 只針對 元素的text()進行匹配,實際開發過程中可能會存在通過id 或者特殊編碼進行 多關鍵字匹配。
改動了下源碼:紅色為改動部分。
process=function(element, collection) {var group;if (element.is("option")) {// modify by yuan 2016.2.15if (query.matcher(term, element.text(), element) || query.matcher(term, element.attr("data-help1"), element) ||query.matcher(term, element.attr("data-help2"), element)) {collection.push(self.optionToData(element));}} else if (element.is("optgroup")) {group=self.optionToData(element);element.children().each2(function(i, elm) { process(elm, group.children); });if (group.children.length>0) {collection.push(group);}}?
html 部分在元素上增加2個屬性,如果存在多個的場合可以根據情況修改。
做個記錄,方便碰到類似情況的朋友
轉載于:https://www.cnblogs.com/yuanhuaming/p/5190058.html
總結
以上是生活随笔為你收集整理的关于 jquery select2 多个关键字 模糊查询的解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: logback 配置
- 下一篇: [转]Spring事务tx:annota