views:

1335

answers:

1

I'm using the auto_complete plugin and have a simple autocomplete textfield by writing this in my controller:

class PrivateMessagesController < ApplicationController
  auto_complete_for :role, :name

and this in my view:

<label for="recipient">To:</label>
    <%= text_field_with_auto_complete :role, :name %>

I want to improve the autocompletion now by:

  • Enabling multiple autocomplete items to be inserted in a textfield, using comma as a tokenizer
  • Putting in conditions. e.g. only showing the names of certain Roles that fit a certain criteria
  • Having each autocomplete item displayed in a vertical list, rather than simply separated by a space.
+1  A: 

try simple autocomplete rails plugin it add a bit more flexibility e.g.

autocomplete_for :post, :title do |items|
  items.map{|item| "#{item.title} -- #{item.id}"}.join("\n")
end

and its unobstrusive so you can add your own js to modify the displayed tems

grosser