Autosuggest Some More!

The second part of my three-part series on how to create an autosuggest textbox (to emulate Google Suggest) is now up on WebReference. I got a lot of positive feedback on the first part, and I hope everyone enjoys this one just as much.

Comments

  1. wangvisual

    Great, but typeahead does not work correctly if type too fast.

  2. Nicholas C. Zakas

    Well, I never promised it would work under all conditions. The article is meant to be a guide for the 90% use case. Naturally I can&#039t anticipate everyone&#039s use cases. But then again, if I did, what would be left for you guys to figure out? ;-)

  3. Glyn

    Do you know when they plan on publishing the third part? &#039Google sugges&#039t gets around the "typeahead does not work correctly if type too fast" problem by using timers in their code that wait a short period of time before calling the autosuggest code.

  4. Nicholas C. Zakas

    Glyn, I&#039m still in the middle of writing the third part, so probably not until next week.

    I&#039m aware of how Google Suggest used timers, but I&#039m always weary of using other&#039s techniques in my articles. The usage agreement for Google Labs specifically states that you&#039re not supposed to publicly post anything for any of the code they have, and I take that agreement very seriously. I figure that people will use what I wrote in the article as a starting point to build more complex functionality.

  5. Biren Roy

    You don&#039t actually need a timer to fix the typeahead problem; all you need is a mutex that prevents handleKeyUp from executing requestSuggestions(this, true) twice in sequence.

Understanding JavaScript Promises E-book Cover

Demystify JavaScript promises with the e-book that explains not just concepts, but also real-world uses of promises.

Download the Free E-book!

The community edition of Understanding JavaScript Promises is a free download that arrives in minutes.