【问题标题】:Autocomplete search input with EasyAutocomplete plugin with multiple values使用具有多个值的 EasyAutocomplete 插件自动完成搜索输入
【发布时间】:2018-06-08 17:37:18
【问题描述】:

我正在使用 EasyAutocomplete 插件来自动完成搜索框,当我只搜索一种类型时,插件工作正常。我的意思是我只有一个搜索选项,而我希望可以使用多个值进行搜索,即按姓名或姓氏等。

这是我的代码:

var options = {
        url: "https://coincap.io/front",

        getValue: "long",

        template: {
            type: "description",
            fields: {
                description: "short"
            }
        },

        list: {
            match: {
                enabled: true
            },

        },

        theme: "plate-dark"
    };

    $("#searching").easyAutocomplete(options);

现在这是我获取加密货币值的 api,目前我正在使用其 long 名称进行搜索,它工作正常,但我还想使用 short 名称进行搜索。

对不起我的英语不好..我希望你有我的问题。 谢谢

【问题讨论】:

    标签: jquery autocomplete


    【解决方案1】:

    这个插件允许使用函数,通过函数你可以做到这一点。

    var options = {
        url: "https://coincap.io/front",
    
        getValue: function(element){
                     return element.long+" - "+element.short;
                  },
       /*
        template: {
            type: "description",
            fields: {
                description: "short"
            } 
        }, */
    
        list: {
            match: {
                enabled: true
            },
    
        },
    
        theme: "plate-dark"
    };
    
    $("#searching").easyAutocomplete(options);
    

    【讨论】:

      猜你喜欢
      • 2014-12-18
      • 1970-01-01
      • 2023-01-20
      • 1970-01-01
      • 2018-03-31
      • 1970-01-01
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多