我正在尝试使用JQuery Autocomplete搜索我的网站。
我面临的问题是,数据显示正确。但是当我尝试选择任何项目时。什么都没发生。选择事件不会触发。
我的aspx代码如下:如果此代码有问题,请帮助我。
我的理解是,如果我从自动填充结果中选择任何项目,则应出现“已选择”消息。
<script type="text/javascript">
$(document).ready(function () {
$("input#autocomplete").autocomplete("Search.ashx",
{
delay: 0,
max: 30,
min: 10,
width: 300,
formatItem: function (data, i, n, value) {
var temp = value.split(",")[3];
temp = temp.replace(" ", "-");
var result = "<table><tr><td> <a href='" + value.split(",")[2] + "'><img style = 'width:40px;height:50px' src= images/mobiles/" + value.split(",")[1] + " /> " + "</a></td><td style='Vertical-Align:Top'> <a href='" + value.split(",")[2] + "'>" + value.split(",")[0] + "</a></td></tr></table>";
return result;
},
select: function (e, ui) {
alert("selected!");
}
});
});
答案 0 :(得分:0)
<script type="text/javascript">
$(document).ready(function () {
$("input#autocomplete").autocomplete("Search.ashx",
{
delay: 0,
max: 30,
min: 10,
width: 300,
source: function (data, i, n, value) {
var temp = value.split(",")[3];
temp = temp.replace(" ", "-");
var result = "<table><tr><td> <a href='" + value.split(",")[2] + "'><img style = 'width:40px;height:50px' src= images/mobiles/" + value.split(",")[1] + " /> " + "</a></td><td style='Vertical-Align:Top'> <a href='" + value.split(",")[2] + "'>" + value.split(",")[0] + "</a></td></tr></table>";
return result;
},
select: function (e, ui) {
alert("selected!");
}
});
});
</script>