我有自动完成返回:
$("#_results").autocomplete({
source: data1,
minLength: 0,
selectFirst: true,
select: function(event, ui) {
if(event.keyCode == 13){
window.open(ui.item.url);
}
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
if(item.label == "No results found"){
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a href=\'#\' title='No results found' target=\'_self\'>" + "<span class='apptitle'>" + item.title + "</span>" + "<br />" + "<span class='descrip'>" + item.description + "</span>" + "</a>")
.appendTo( ul )
}
else if(item.support_url != ""){
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a href=\'" + item.url + "\' title='Click here to launch' target=\'_blank\'>" + "<span class='apptitle'>" + item.title + "</span>" + "<br />" + "<span class='descrip'>" + item.description + "</span>" + "<a href=\'" + item.support_url + "\' target=\'_blank\'><img src=\'http://supportcentral.ge.com/images/HELP_FORMS.GIF\' /><span class=\'supportText\'>Please click here for support</span></a>" + "</a> <hr width='80%' align='center'>")
.appendTo( ul )
}else{
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a href=\'" + item.url + "\' title='Click here to launch' target=\'_blank\'>" + "<span class='apptitle'>" + item.title + "</span>" + "<br />" + "<span class='descrip'>" + item.description + "</span>" + "<a href=\'http://supportcentral.ge.com/cases/case_log_quickcase.asp?prod_id=139545&cat_id=92831\'><img src=\'http://supportcentral.ge.com/images/HELP_FORMS.GIF\' /><span class=\'supportText\'>No support URL was provided. Please suggest one.</span></a>" + "</a> <hr width='80%' align='center'>")
.appendTo( ul )
}
};
我不知道自己更改了什么,但是现在单击结果时,它不会触发href。我可以右键单击它,然后选择“打开新窗口/选项卡”,它可以正常工作。还要按Enter触发要打开的URL。但是用鼠标单击它除了隐藏列表没有其他作用(好像它做了它应该做的一样)。当我看HTML时,对我来说看起来是正确的:
<a target="_blank" title="Click here to launch" href="some_url_cant_post_more_than_1_on_here" class="ui-corner-all" tabindex="-1"><span class="apptitle">Some Title</span><br><span class="descrip">Description of App</span></a>
有人有想法么?
最佳答案
原来最新版本的jQuery ui min打破了点击。我恢复为旧版本。
关于javascript - jQuery自动完成-结果链接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4369664/