Question

I would like to make a typeahead that searches from Items.all, Objects.all, and Stuff.all (probably a total of a thousand or so things that do not really change) and the suggestions brought up by the typeahead are links such that when they are clicked, take you to their page, just like <= link_to Item.name, Item %> does.

I'm not quite sure how to do this. I'm using bootstrap, so it seems I have to modify bootstrap-typeahead's behavior somehow.

I'm wondering maybe if there's an efficient way to do this so that the list of Items, Objects, and Stuff are all loaded once and kept client-side or something, then the typeahead box could be on every page of the application and work the same.

Just like Twitter's site where their typeahead search retrieves links when you search for people, and one just has to click the links that appear below the text box to go to the page.

Was it helpful?

Solution 2

I solved this by using the rabl gem to generate json files containing data from my model and the twitter-typeahead-rails gem to implement twitter's typeahead.js in my application.

OTHER TIPS

I have had good success with the soulmate gem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top