I have a simple search form that looks something like:
app/views/search/index.html.erb
<%= form_for @search, :as => :search, :remote => true, :url => {:action => "query"}, :html => {:id => 'search-form'} do |f| %>
...
<% end %
<div id="search-results"></div>
*app/controllers/search_controller.rb*
def index
@search = SearchCriteria.new
end
def query
@search = SearchCriteria.new(params[:search])
# otherwise, perform search...
@summaries = do_search @search
respond_to do |format|
format.js
end
end
I then have a js.erb template: *app/views/search/_query.js.erb*
$('#search-results').update("<%= escape_javascript(render(@summaries)) %>");
However, I don't see anything being put into the 'search-results' div. Do I need some sort of template in order to render "@summaries"? If so, what would it be named and where would I place it (i.e. app/views/search?) (i am using jquery and rails 3)
Thanks.
you should rename your template file:
app/views/search/_query.js.erb => *app/views/search/query.js.erb
underscore is unnecessary
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With