Mike Dershowitz
2007-Apr-28  17:27 UTC
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 -%>
<span class="boldTextBlk">
<table  border="0" cellpadding="1"
cellspacing="1">
    <tr>
      <td><b>To</b></td>
      <td align="left"><%= text_field_tag :to, nil, :size
=> "15" %>
   
           
   
           
   
           
        <%= submit_tag "Send!" %>
    </td>
    </tr>
    <tr>
      <td><b>Subject</b></td>
      <td align="left"><%= text_field_tag :subject, "Re:
#{msg.subject}", :size => "30" %>
    </td>
    </tr>
      <td><b>Message</b></td>
      <td><%= text_area_tag :body, nil, :size => "45x3"
%>
    <%= hidden_field_tag :msg_id, msg.id %>
    </td>
    </tr>
  </table>
</span>
<% 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
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Apr-30  12:54 UTC
Re: RJS error I don''t understand - multiple replace_html
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
On 4/28/07, Mike Dershowitz
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> 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 -%>
> <span class="boldTextBlk">
> <table  border="0" cellpadding="1"
cellspacing="1">
>     <tr>
>       <td><b>To</b></td>
>       <td align="left"><%= text_field_tag :to, nil,
:size => "15" %>
>    
           
>    
           
>    
           
>         <%= submit_tag "Send!" %>
>     </td>
>     </tr>
>     <tr>
>       <td><b>Subject</b></td>
>       <td align="left"><%= text_field_tag :subject,
"Re:
> #{msg.subject}", :size => "30" %>
>     </td>
>     </tr>
>       <td><b>Message</b></td>
>       <td><%= text_area_tag :body, nil, :size =>
"45x3" %>
>     <%= hidden_field_tag :msg_id, msg.id %>
>     </td>
>     </tr>
>   </table>
> </span>
> <% 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
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---