简体   繁体   English

带有子项的jQuery-ui自动完成

[英]jQuery-ui Autocomplete with subitems

I'm trying to implement autocomplete with extra info showing next to the suggestion. 我正在尝试使用建议旁边显示的额外信息来实现自动完成。 Whenever I hover over the item, it should show some extra details about items. 每当我将鼠标悬停在该项目上时,它都应显示有关该项目的一些额外详细信息。

I tried adding extra div with autocomplete's dynamic positions, but no luck. 我尝试添加带有自动完成功能动态位置的额外div,但是没有运气。

If anyone has any idea, I'm all ears! 如果有人有什么主意,我全都听!

Thanks 谢谢

You can take a look here -> https://jqueryui.com/autocomplete/#custom-data on how to create a jQuery UI Autocomplete with extra info. 您可以在这里-> https://jqueryui.com/autocomplete/#custom-data了解如何使用附加信息创建jQuery UI自动完成功能。 (make sure to use their defined names "label, desc" etc). (请确保使用其定义的名称“ label,desc”等)。

After you create the jquery ui autocomplete with the info you need you can use jquery .hover() to display information however you need (in case you dont like the default example on UI page) . 使用所需的信息创建jquery ui自动完成后,可以使用jquery .hover()显示所需的信息(以防您不喜欢UI页面上的默认示例)。 https://api.jquery.com/hover/ https://api.jquery.com/hover/

Edit: Just to make it easier for you to understand, instead of appending the item.desc while UI autocompletes you can user hover(item.desc) 编辑:只是为了使您更容易理解,而不是在UI自动完成时附加item.desc,您可以将鼠标悬停在(item.desc)

I'm talking about this part of the code -> 我在说这部分代码->

.autocomplete( "instance" )._renderItem = function( ul, item ) {
  return $( "<li>" )
    .append( "<div>" + item.label + "<br>" + item.desc + "</div>" )
    .appendTo( ul );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM