Forum: Ruby on Rails AJAX replace_html error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8e7e5b934fcbcdfb475072685755457f?d=identicon&s=25 Taylor Strait (taylorstrait)
on 2009-01-05 16:24
I have a query form that performs a complex SQL query based on form
params and then creates a bunch of @user_x collections for display
purposes.  However, AJAX is bombing out with what seems to be a simple
error.  When I submit the form, instead of replacing the desired partial
(under the form) it displays:
======
try {
Element.update("CONTENTS OF PARTIAL SNIPPED);'); throw e }
======
The partial correctly updates but something small is wrong preventing
the in-place update.

FORM VIEW
<%= javascript_include_tag :defaults %>
<% form_for :query, :url => {:action => :query_results} do |f| %>
FORM CONTENTS SNIPPED
<% form_remote_tag :url => {:action => :query_results} do %>
      <%= submit_tag "Query" %>
    <% end %>
<% end %>

ACTION
  def query_results
    @conditions = conditionalize(params[:query])
    @users = User.find(:all, :conditions => @conditions)
      respond_to { |format| format.js }
  end

QUERY_RESULTS.JS.RJS
page.replace_html("query_results", :partial => "query_results")
8e7e5b934fcbcdfb475072685755457f?d=identicon&s=25 Taylor Strait (taylorstrait)
on 2009-01-05 16:27
Forgot an important part!

FORM VIEW (below form)
<% if @users %>
  <div id="query_results">
    <%= render(:partial => "query_results")%>
  </div>
<% end %>
This topic is locked and can not be replied to.