TypeError: html has no properties

I'm trying to update a div after form submission, for some reason it
is dying on this line:

render :update do |page|
  page[:body].replace_html :url => body_report_show(:id =>
params[:report_id])
end

I get an alert window that says

RJS error:

TypeError: html has no properties

Help??

Typically that means that there is not an element on the page with that id.

Glen wrote:

To clarify, look at you source html and make sure there is an element

It should still be there. At this point in the application that div
has been updated at least twice but I don't use replace anywhere.

Is there a way to pass data forward so that I could test with
rendering a partial? I would need to set the @report variable again
somehow for the partial.

The only other thing that immediately comes to mind is to validate your
html after the last successful update to make sure it didn’t break.
Since JS depends on a “mostly” valid dom, that could be it. If you are
using Firefox, the web developer tool bar has the ability to validate
local html and also the ability to view the “generated source” which
will show the source for the page after js has modified it.

For rendering as a partial, you can either directly access @report in
the partial, or decouple the partial by setting a local variable like
this:

  render :update do |page|
page[:body].replace_html :partial => 'a_partial', :locals => {:report => @report}
end

This would set the local variable “report” in the partial to the value
of @report.

Hope this helps.

Glen wrote:

Thanks, William.

I actually just got done doing the latter and it is working now. The
code is getting a bit sloppy, I really need to go through and clean it
up.

Thanks again for your help.