zoukankan      html  css  js  c++  java
  • 关于 jquery select2 多个关键字 模糊查询的解决方法

    select2 只针对 元素的text()进行匹配,实际开发过程中可能会存在通过id 或者特殊编码进行 多关键字匹配。

    改动了下源码:红色为改动部分。

                        process=function(element, collection) {
                            var group;
                            if (element.is("option")) {
                                // modify by yuan 2016.2.15
                                if (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个属性,如果存在多个的场合可以根据情况修改。

    做个记录,方便碰到类似情况的朋友

  • 相关阅读:
    接口测试基础07
    性能测试基础01
    接口测试基础06
    将java list转换为js的数组
    java 网络编程
    java分页
    单例模式
    适配器模式
    抽象工厂模式
    工厂模式
  • 原文地址:https://www.cnblogs.com/yuanhuaming/p/5190058.html
Copyright © 2011-2022 走看看