Piyush Gupta
unread,Sep 20, 2007, 5:18:40 AM9/20/07Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bangal...@googlegroups.com, comp.la...@googlegroups.com, ra...@circlesource.com, rails...@googlegroups.com, ruby-tal...@googlegroups.com, ruby...@ruby-lang.org, rubyonrail...@googlegroups.com, rubyonra...@googlegroups.com, rubyonra...@googlegroups.com, ujs4...@googlegroups.com
Hi friends,
I was using the rails recipes for the feature called Lightning fast auto completer where we search and save the contents to be displayed in the JavaScript Array .
something like in some .js file
var authors = new Array(<%= @authors.size %>);
<% @authors.each_with_index do |author, index| %>
authors[<%= index %>] = "<%=
author.name %>";
<% end %>
and do this in the head section the rhtml file <head>
<%= javascript_include_tag :defaults %>
<script src="/book/authors_for_lookup" type="text/javascript"></script>
and in the controller def authors_for_lookup
@authors = Author.find(:all)
@headers[' content-type' ] = ' text/javascript'
end
--
Piyush
09916133729
<Bangalore>
http://ctrlshiftesc.blogspot.com/