【问题标题】:jQuery autocomplete - result linkjQuery 自动完成 - 结果链接
【发布时间】:2010-12-07 22:10:42
【问题描述】:

我有自动完成返回:

   $("#_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。我可以右键单击它并选择“打开新窗口/标签”,这样就可以了。按下回车键也会触发 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>

有人有什么想法吗?

【问题讨论】:

    标签: javascript jquery user-interface autocomplete


    【解决方案1】:

    原来最新版的jquery ui min 破坏了点击。我恢复到旧版本。

    【讨论】:

      猜你喜欢
      • 2016-08-07
      • 2011-05-30
      • 1970-01-01
      • 2011-01-04
      • 1970-01-01
      • 2017-01-13
      • 2011-09-27
      • 2011-09-08
      • 2011-07-21
      相关资源
      最近更新 更多