Ester Lin
Ester Lin

Reputation: 617

Rails/JQuery: Auto complete without loading entire database into browser

I know that JQuery has a pretty nice auto complete library, but it does have one shortcoming. You must load all the available entries onto the page from when the page loads. This, of course, might be impractical for larger databases.

I know that auto complete offers an option to only start searching after a certain number of chars. Is there some way, either through rails JavaScript or some combination, to load the auto-complete array after the first four chars are typed in? If there us some other library that does this, that would work too.

Upvotes: 2

Views: 78

Answers (1)

Kichnipan
Kichnipan

Reputation: 35

You don't have to use any libraries. Just use HTML5 datalist and javascript

http://jsfiddle.net/4smuhg4d/3/

When you typed number of chars grater than 4 then will call ajax, and append the result to input as list.innerHTML

Upvotes: 1

Related Questions