views:

164

answers:

2

my autocomplete call is showing nothing right now, because the div that i am inserting the ul into has its style set to display:none. using firebug, i can see the results are returned in a proper unordered list tag and when i edit the html from the firebug console and remove the style="display:none;", i see the autocomplete results. i added css for the autocomplete tags that are generated but this is getting overwritten by prototype 1.6.1/scriptaculous 1.8.3. also, i'm using rails 1.2.2

here is the code from my view:

<script type="text/javascript">
  new Ajax.Autocompleter("autocomplete", "autocomplete_choices", "/campaigns/title_list", {tokens: ',', paramName: 'title'});
</script>

<input type="text" id="autocomplete" name="autocomplete_parameter"/>
   <div id="autocomplete_choices" class="autocomplete"></div>

and here my controller action and partial:

def title_list
  camp_title = params[:title]
  @titles = Campaign.find(:all, :conditions => ["title ilike ?", "%#{camp_title}%"], :select => :title).collect { |camp| camp.title }
  render :partial => "title_list"
end

_title_list.rhtml

<ul>
  <% @titles.each do |t| %>
      <li> <%= t %> </li>
  <% end %>
</ul>

here's what i seen in firebug:

<div style="display: none; position: absolute; left: 8px; top: 123px; width: 155px;" id="autocomplete_choices">
  <ul>
    <li class="selected"> DirecTV Defender (Best Deal Ever) </li>
    <li class=""> Defender DirecTV </li><li class=""> DirecTV Defender - Collections </li>
    <li class=""> Defender DirectTV (Gotham Direct) </li>
  </ul>
</div>

any suggestions would be greatly appreciated.

-h

A: 

I am having the same problem. I read in some posts that it is a problem with some versions of scriptaculous/prototype... but I wasn't able to find a working version either. Can anyone who has the thing actually working pls post his prototype and scriptaculous versions?

Gabriel
thanks gabriel. i'll give it a try and see if it works for me as well.
hubert
A: 

You need to go into the auto_complete helper (inside the vendor directory) and change the line items.uniq to items.uniq.join The reason is a change in the to_s behavior of Arrays in Ruby 1.9. Worked fine for me like this.

Gabriel