Four Key Reasons to Learn Markdown
Back-End Leveling UpWriting documentation is fun—really, really fun. I know some engineers may disagree with me, but as a technical writer, creating quality documentation that will...
Auto-Complete is a great tool when it provides possible results BEFORE you finish typing. Unfortunately, using Rails’s included AJAX helpers to query the database as you type often results in a large delay before matches are returned.
However, there is a lightning-quick option: pre-fetch the results in a Javascript array.
In a client project, users can add labels to events on their calendar. To prevent users from creating variations of the same label name (i.e. – “favorite” vs. “favorites”), we needed to provide faster auto-complete functionality than that available through Rails’s provided AJAX helpers.
We created a simple helper method for this case (special thanks to Chad Fowler and his Rails Recipes book for the inspiration).
Take a look at the local_auto_complete_field helper method. TXT (Editor’s note: this is no longer available.)
To call the function from your views:
<br></br> <%= local_auto_complete_field('name',@labels) %><br></br>
In the above example, we are adding JavaScript-powered auto-complete functionality to the 'name'
text field. The JavaScript array is generated by calling #name
on each element in the @labels
array. To override this behavior:
<%= local_auto_complete_field('name',@labels, :method => 'description') %>
Here’s to faster auto-completion!
Writing documentation is fun—really, really fun. I know some engineers may disagree with me, but as a technical writer, creating quality documentation that will...
Humanity has come a long way in its technological journey. We have reached the cusp of an age in which the concepts we have...
Go 1.18 has finally landed, and with it comes its own flavor of generics. In a previous post, we went over the accepted proposal and dove...