jquery ui auto完成不起作用

时间:2011-04-04 06:09:30

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

我正在使用jquery ui auto with ajax,这是我使用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;
        }
    });

我正在点击自动完成列表

2 个答案:

答案 0 :(得分:0)

似乎工作

<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"

答案 1 :(得分:0)

与jquery validate 1.7发生冲突,因此转移到了1.8的验证