gpt4 book ai didi

javascript - jQuery ui 自动完成 - renderItem url's

转载 作者:行者123 更新时间:2023-11-28 02:50:54 24 4
gpt4 key购买 nike

使用:

.data( "autocomplete" )._renderItem = function( ul, item ) {
var temp = item.url.substring(16, item.url.length)
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.value + "<br>" + item.url + "<br>" + item.description + "<br>" + "Support URL: " + item.support_url + "<br>" + "Contact: " + "<a href=" + item.contact + ">Test</a>" + "<br />" + "</a>" )
.appendTo( ul )

jQuery 正在解析 item.url 并自动将其设为 html 中的 href。我想手动控制 href 的内容,以便我可以执行类似 "<a href='" + item.url + ">" + item.title "</a>" 的操作

jQuery 现在处理这个问题的方式是将 item.url 设为 href 并添加我的 html href,但没有正确使用标题。

在旧版本的自动完成中,我能够执行 .result(function(event, item) {
location.href = item.url;
});
但这似乎在这里不受支持。

最佳答案

您可以提供一个回调,该回调将在选择某个项目时执行。

$("#input").autocomplete({
source: mySource,
select: function(event, ui){
window.location = ui.item.url;
}
});

引用号:http://docs.jquery.com/UI/Autocomplete#event-select

关于javascript - jQuery ui 自动完成 - renderItem url's,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3787914/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com