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 });

    $(".ui-autocomplete-loading").ajaxStart(function(){
    $(this).show();
    });

    $(".ui-autocomplete-loading").ajaxStop(function(){
    $(this).hide();
    });

    $(document).ready(function() {
    $("#ui_query").autocomplete({
    source: [
             "Bleach",
             "Naruto",
             "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",
             "Freezing",
             "To Aru Majutsu No Index 2",
             "IS: Infinite Stratos",
             "Gosick",
             "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",
             "11eyes",
             "Code Geass: Hangyaku no Lelouch R2",
             ]
    });
    });

thanks in advance

  • 写回答

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.

    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试