jQuery自动完成 - 结果链接

时间:2010-12-06 18:28:52

标签: javascript jquery user-interface autocomplete

我有自动完成返回:

   $("#_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>

有人有什么想法吗?

1 个答案:

答案 0 :(得分:0)

原来最新版本的jquery ui min打破了点击。我又回到了旧版本。