我是JS和jQuery的新手。我有一系列事件如下:
data {...}
[0]: {...}
[1]: {...}
[2]: {...}
[3]: {...}
...
[40]: {...}
length: 40
data[0] {...}
__type: "acme.acmeSystem.EventManagement.Event"
Amenity: {...}
DateFrom: "/Date(1326952800000)/"
DateTo: "/Date(1326952800000)/"
Title: "Birthday party"
Description: "Friends coming over for a party."
Food: false
Id: 3
IsPrivate: true
Notes: ""
NumberOfPeople: "Less than 10"
Status: {...}
TimeFrom: "8:30 AM"
TimeTo: "11:30 AM"
User: {...}
如何将此数组绑定到自动完成插件,以便某人只需开始在文本框中键入事件的标题以查找匹配的事件?当它在下拉列表中显示事件列表时,他们可以单击他们选择的事件,并将它们带到该事件的详细信息页面(例如:mywebsite.come / Events / EventDetails.aspx?ID = 50)。
我试过这样做:
$( “#EventsSearch”)。自动完成({ 来源:数据 });
我只是想做这样的事情,但是当在下拉列表中点击其中一个事件时,它会将它们带到详细信息页面。感谢。
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
<div class="demo">
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</div><!-- End demo -->
答案 0 :(得分:0)
在锚标记<a href='desired url'>autocomplete suggestion</a>
中包含自动填充建议。因此,当他们被点击时,页面会重定向到您想要的位置。