jQuery用户界面自动完成不带过滤器 [英] jquery ui autocomplete without filter

查看:143
本文介绍了jQuery用户界面自动完成不带过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示用户自动完成所有的选择,不管是什么文字他在场上已经写?也许我需要一些其他的插件?

I need to show user all autocomplete choices, no matter what text he already wrote in the field? Maybe i need some other plugin?

$('#addressSearch').autocomplete("search", "");

这是行不通的。

推荐答案

有两种情况:


  1. 您正在使用本地数据源。这是很容易在这种情况下做到:

  1. You're using a local data source. This is easy to accomplish in that case:

var src = ['JavaScript', 'C++', 'C#', 'Java', 'COBOL'];
$("#auto").autocomplete({
    source: function (request, response) {
        response(src);
    }
});


  • 您正在使用远程数据源。

  • You're using a remote data source.

    $("#auto").autocomplete({
        source: function (request, response) {
            // Make AJAX call, but don't filter the results on the server.
            $.get("/foo", function (results) {
                response(results);
            });
        }
    });
    


  • 无论哪种方式,你需要一个函数传递给参数,避免过滤结果。

    Either way you need to pass a function to the source argument and avoid filtering the results.

    下面是与本地数据源的例子: http://jsfiddle.net/andrewwhitaker/e9t5Y/

    Here's an example with a local data source: http://jsfiddle.net/andrewwhitaker/e9t5Y/

    这篇关于jQuery用户界面自动完成不带过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆