I purchased a copy of Chad Fowler’s excellent Rails Recipes recently. He’s got a few recipes dealing with edit in place and one about building local autocomplete. I pulled these recipes together into a single solution that gives me an edit in place with local autocomplete functionality.
Rails Helper
I created a couple Rails helper functions to encapsulate the functionality so I can call it with one function in my view. View the source, with syntax highlighting.
JavaScript
I had to extend the existing Scriptaculous code to support my specific functionality. View the source, with syntax highlighting.
Implementation
Now, you just include the JS in your page and use the new helper to build the UI component.
<%= in_place_editor_field_with_local_autocomplete :recipe,
:cookbook_title,
{},
{},
{
:catalog => ‘cookbooks’,
:fullSearch => true,
:frequency => 0,
:minChars => 2
}
%>
Update
Ola Bini has developed an InPlaceEditor with Autocomplete plugin for Rails. Definitely worth a look.
Entries (RSS)