【问题标题】:jquery ui auto complete not workingjquery ui自动完成不起作用
【发布时间】:2011-04-26 12:59:42
【问题描述】:

我正在使用带有 ajax 的 jquery ui 自动完成,这是我使用 firebug 得到的 json 响应

[{"value":" test","url":"\/social\/profile\/46","label":" test"},
{"value":" test","url":"\/social\/profile\/47","label":" test"},
{"value":"test tset","url":"\/social\/profile\/62","label":"test tset"},
{"value":"test test","url":"\/social\/profile\/126","label":"test test"}]

这是代码

// Using jQuery UI's autocomplete widget:
    $('#term').autocomplete({
        minLength    : 4,
        source        : rootPath+'/search',
        select: function(event, ui) 
        {
            window.location =  ui.item.url;
        }
    });

我正在获取自动完成列表

【问题讨论】:

标签: jquery jquery-ui jquery-ui-autocomplete


【解决方案1】:

似乎有效

<script>
$(function ()
{       
    $("#text").autocomplete({
            source: "something.php",
            type:"json",
            select: function(event, ui) 
            {
                window.location =  ui.item.url;
            }
        });
})
</script>
<input type="text" name="text" id="text"/>

回复

[{"value":" test","url":"/social/profile/46","label":" test"},
{"value":" test","url":"/social/profile/47","label":" test"},
{"value":"test tset","url":"/social/profile/62","label":"test tset"},
{"value":"test test","url":"/social/profile/126","label":"test test"}]

我猜回复应该是"/social/profile/126" 而不是\/social\/profile\/126"

【讨论】:

    【解决方案2】:

    与 jquery validate 1.7 发生冲突,因此移至 validate 1.8

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-01
      • 1970-01-01
      • 2011-06-11
      相关资源
      最近更新 更多