【问题标题】:jquery ui autocomplete giving an error of "Uncaught TypeError: Cannot read property 'PAGE_UP' of undefined"jquery ui 自动完成给出错误“未捕获的类型错误:无法读取未定义的属性 'PAGE_UP'”
【发布时间】:2012-06-26 16:50:16
【问题描述】:

我正在尝试使用 jquery ui 自动完成功能,当您在具有自动完成功能的输入字段中键入内容时,始终出现以下错误:

Uncaught TypeError: Cannot read property 'PAGE_UP' of undefined

我的页面中包含以下文件:

  • jquery-1.7.2.min.js
  • jquery-ui-1.8.21.custom.min.js
  • jquery-ui-1.8.21.custom.css

这是使用自动完成的代码:

$('input#searchFor').autocomplete({
        source:function(req,add){
            $.getJSON("/index.php/search/autoCompleteHandler?q=?&section="+$('input#searchFor').attr("searchDesc"),req,function(data){
                var suggestions = [];

                $.each(data,function(i,val){
                    suggestions.push(val.name);
                });

                add(suggestions);
            });
        }
    });

我不知道出了什么问题。任何帮助将不胜感激。

【问题讨论】:

标签: jquery-ui jquery-ui-autocomplete


【解决方案1】:

remote data source 的 jQueryUI 示例文档显示远程数据源应该像这样完成:

$(function() {
        $( "#birds" ).autocomplete({
            source: "search.php",
            minLength: 2,
            select: function( event, ui ) {
                //the code to execute when an item is clicked on
            }
        });
    });

看起来 source 只需要是一个 url。您可以查看 Chrome 中的 ajax 请求,找出搜索查询填充的 $_GET 或 $_POST 变量。

根据您的使用情况,使用remote data source with caching 选项可能不是一个坏主意。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-08
    • 2015-07-11
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多