Didn"t forge
2011-04-07 16:06
采纳率: 25%
浏览 37

jQuery UI自动完成

I am trying to get my jQuery UI Autocomplete to work the way I want it but I am not very sure what to do. First I can't get the loading to get working in the input field. I also want jQuery to match the search results by first letter so for example if the source is

apple cola tea carrot

so when you type A it matches any word with "A" first and if you are searching for say "cola" jQuery would highlight each letter as you type in the results portion so you type "co" it will be highlighted here is my current code

$("#ui_query").autocomplete({ autoFocus: true });
$("#ui_query").autocomplete({ disabled: false });
$("#ui_query").autocomplete({ minLength: 2 });



    $(document).ready(function() {
    source: [
             "Level E",
             "Kore wa Zombie desu ka",
             "Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne!!",
             "Mobile Suit Gundam SEED Destiny",
             "Mobile Suit Gundam SEED",
             "One Piece",
             "To Aru Majutsu No Index 2",
             "IS: Infinite Stratos",
             "Mahou Shoujo Madoka Magica",
             "Yumekui Merry",
             "Hyakka Ryouran: Samurai Girls",
             "After War Gundam X",
             "Mobile Suit Gundam",
             "Mobile Suit Gundam 00",
             "Fullmetal Alchemist: Brotherhood",
             "Fullmetal Alchemist",
             "Tengen Toppa Gurren Lagann",
             "Code Geass: Hangyaku no Lelouch",
             "Code Geass: Hangyaku no Lelouch R2",

thanks in advance

图片转代码服务由CSDN问答提供 功能建议


我正在尝试让jQuery UI自动完成功能按我想要的方式工作,但我不确定该怎么做。 首先,我无法在输入字段中进行加载。 我还希望jQuery按首字母匹配搜索结果,例如,如果源是

苹果 可乐 茶 胡萝卜

因此,当您键入A时,它首先将与“ A”匹配的任何单词,并且如果您要搜索“ cola”,则在结果部分中键入时,jQuery会突出显示每个字母,因此在键入“ co”时,它将在此处突出显示 是我当前的代码




     资源: [
              “ E级”,
              “ Kore wa Zombie desu ka”,
              “ Onii-chan no Koto Nanka Zenzen Suki Janain Dakara ne !!”,
              《机动战士高达SEED Destiny》,
              “ IS:无限斯特拉托斯”,
              “ Gosick”,
              “ Mahou Shoujo Madoka Magica”,
              “ Hyakka Ryouran:武士女孩”,
              “ Tengen Toppa Gurren Lagann”,
              “ Code Geass:Hangyaku no Lelouch”,
              “ 11只眼睛”,
              “ Code Geass:Hangyaku no Lelouch R2”,



  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • weixin_33690367 2011-04-07 16:22

    It looks like the jQuery UI autocomplete plugin doesn't support formatting of results before display, unlike it's predecessor. You can see the complete list of features dropped and the equivalent of other features here.

    You can however simulate that effect by writing a custom handler for data. Here is an official demo that does what you want - the source is available.

    This question on SO asked the same thing and monkey-patching the plugin was suggested.

    打赏 评论

相关推荐 更多相似问题