admin 管理员组文章数量: 1086019
In my Rails app, I want to an incremental search (like autoplete) through the Customer
table in the DB, looking for names, and showing the results as you type, Google Instant-style.
My brief research for gems or examples that might help in this scenario didn't provide any useful results.
Is there a Rails way to implement this?
The only issue I can think of is that that having approx. 500k records in the DB (even if the name related columns are indexed) might slow down the responsiveness.
As a solution for that, the ajax request might be triggered only after typing in the first 4-5 characters.
Any other suggestions, leads, issues, ideas, ments?
In my Rails app, I want to an incremental search (like autoplete) through the Customer
table in the DB, looking for names, and showing the results as you type, Google Instant-style.
My brief research for gems or examples that might help in this scenario didn't provide any useful results.
Is there a Rails way to implement this?
The only issue I can think of is that that having approx. 500k records in the DB (even if the name related columns are indexed) might slow down the responsiveness.
As a solution for that, the ajax request might be triggered only after typing in the first 4-5 characters.
Any other suggestions, leads, issues, ideas, ments?
Share Improve this question edited Jun 17, 2011 at 13:55 Marius Butuc asked Jun 17, 2011 at 13:48 Marius ButucMarius Butuc 18.3k23 gold badges80 silver badges111 bronze badges2 Answers
Reset to default 8Use this: Tokeninput
and here is Railscast for it: TokenInput railscast
While I'm not at all familiar with ruby, I use jQuery UI autoplete often. You can trigger it to run only after a certain number of characters are typed (See minLength in 'options').
Also you can pass additional parameters to your server side scripting. I pass one called Limit and set it to a sensible value (10 in most cases), I use this in the SQL query (where rownum <10), that way you don't hammer the database.
本文标签: javascriptGoogle Instantstyle search in Rails3Stack Overflow
版权声明:本文标题:javascript - Google Instant-style search in Rails3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744022424a2520041.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论