Using AutoComplete with ActiveScaffold

9 views
Skip to first unread message

CyberFerret

unread,
Apr 16, 2007, 8:12:57 AM4/16/07
to ActiveScaffold : Ruby on Rails plugin
Hi all,

I want to incorporate an autocompleter field in the create and update
screens of my ActiveScaffold routine. What is the best way of
accomplishing this? Do we need to define a partial field override?

Thanks

Lance Ivy

unread,
Apr 16, 2007, 2:31:28 PM4/16/07
to actives...@googlegroups.com
Yep, I think you want a form override. You might find some tips by searching this Google Group for "autocomplete" ... I've seen some other posts on the topic.

CyberFerret

unread,
Apr 17, 2007, 12:16:31 AM4/17/07
to ActiveScaffold : Ruby on Rails plugin
Searching for 'autocomplete' on this forum doesnt really come up with
much information - there are a couple of feature requests for this,
but no one actually has come up with a solution. I have tried a
partial form override, but now the ActiveScaffold refuses to open up
the 'Create' div.

To summarise, I have an ActiveScaffold component called Worksheets
(worksheets_controller). The field that I want the autocomplete to be
called on is called product_description, so I created a partial
called: /app/view/worksheets/_product_description_form_column.rhtml
within this file, I have:-

<% text_field_with_auto_complete, :product, :description -%>

Also, within the controller, I have:

auto_complete_for :product, :description

Every time I hit the 'Create' button, nothing happens. Where am I
going wrong?


On Apr 17, 3:31 am, "Lance Ivy" <l...@cainlevy.net> wrote:
> Yep, I think you want a form override. You might find some tips by searching
> this Google Group for "autocomplete" ... I've seen some other posts on the
> topic.
>

Michael Latta

unread,
Apr 17, 2007, 12:00:35 PM4/17/07
to actives...@googlegroups.com
I went the route of using a field level partial override with the
following:

<div style="{height: 100px;}">
<label for="@record[:identity_type]">Identity Type</label>
<%= text_field_tag 'record[identity_type]', @record[:identity_type]%>
<div class="auto_complete" id="identity_type_autocomplete_<%=@record
[:id]%>" style="{height: 80px;}"></div>
<%= javascript_tag("new Autocompleter.Local('record[identity_type]',
'identity_type_autocomplete_#{@record[:id]}', ['User', 'Group',
'AdminUser'], {fullSearch: true, frequency: 0, minChars: 1});") -%>
</div>

In this case the set of options was small and so I used the
javascript version of autocomplete rather than the server based one.

Michael

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "ActiveScaffold : Ruby on Rails plugin" group.
> To post to this group, send email to actives...@googlegroups.com
> To unsubscribe from this group, send email to activescaffold-
> unsub...@googlegroups.com
> For more options, visit this group at http://groups.google.com/
> group/activescaffold?hl=en
> -~----------~----~----~----~------~----~------~--~---
>

Reply all
Reply to author
Forward
0 new messages