使用具有多个值的EasyAutocomplete插件自动完成搜索输入

时间:2017-12-28 06:52:54

标签: jquery autocomplete

我使用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名称进行搜索。

抱歉我的英语不好..我希望你能解决我的问题。 感谢

1 个答案:

答案 0 :(得分:4)

此插件允许使用功能,通过功能可以执行此操作。

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);
相关问题