小编spe*_*ked的帖子

jQuery ui autocomplete - renderItem

我正在使用_renderItem来修改结果列表

.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 )
Run Code Online (Sandbox Code Playgroud)

这具有自动标记任何看起来像url作为href的行为的行为.我想将整个项目作为链接

在较旧的自动完成中,这样做:

 .result(function(event, item) {
   location.href = item.url;
  });
Run Code Online (Sandbox Code Playgroud)

但是这不再需要支持了.

有谁知道我怎么做:

1)使用类似于.result函数的东西,只需将整个项目作为链接

2)修改_renderItem,使其不会自动将看起来像URL的字符串转换为href的

谢谢.

javascript jquery jquery-ui autocomplete

5
推荐指数
3
解决办法
8032
查看次数

标签 统计

autocomplete ×1

javascript ×1

jquery ×1

jquery-ui ×1