RJS error I don't understand - multiple replace_html

Hello:

I’ve got a remote-link-to that’s replaacing a div section quite nicely.
the HTML that get’s injected into the form in the first place has a form
in it. Here’s waht gets injected in a div on a page:

The link_to_remote that does this is here:

<%= link_to_remote “Forward”,
:url => { :controller => ‘messages’, :action =>
‘forward’, :id => msg.id } %> |

the “forward” function it calls is here:

def forward
@message = Message.find(params[:id])
render :update do |page|
page[“reply-forward#{@message.id}”].replace_html :partial =>
‘fmessage’, :locals => { :msg => @message}
end
end

The partial that gets injected is here ("_fmessage.rhtml"):

<% form_tag ‘/messages/create_forward’ do -%>

To <%= text_field_tag :to, nil, :size => "15" %>                                     <%= submit_tag "Send!" %>
Subject <%= text_field_tag :subject, "Re: #{msg.subject}", :size => "30" %>
Message <%= text_area_tag :body, nil, :size => "45x3" %> <%= hidden_field_tag :msg_id, msg.id %>
<% end %>

And the method that the submit tag calls is quite simple - the DB
inserts it does work fine. But what doesn’t, is when I try and
essentially empty-out the original div that the partial gets put into.
Here’s the code I’m trying:

render :update do |page|
page[“reply-forward#{@reply_to.id}”].update :partial => ‘empty’
end

(NOTE: I also tried replace_html, but that didn’t work either. The
error it’s giving is:

try {
$(“reply-forward23”).update({partial: “empty”});
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());
alert(’$(“reply-forward23”).update({partial: “empty”});’); throw e }

I’m sure this an error others have encountered. I tried to give you a
complete picture. I’m just not sure why I can re-replace (essentially,
that’s what I’m doing).

Thank you very much in advance for your help!

Mike

The proper form of replace_html is:

page.replace_html dom_id, *render_options

In your case:

render :update do |page|
page.replace_html “reply-forward#{@reply_to.id}”, :partial => ‘empty’
end

Anything that isn’t recognized by the JavascriptHelper gets turned
directly
into Javascript (e.g. your update method).

Jason

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs