Vinod Krishnan wrote:> Hi Everyone,
> I am still only 1 week old on Rails and I am trying to implement an
> AJAXy "Add comment" sheet. On the post for a new comment, I want
to
> use form_tag_remote. I would like to use a partial that I want to
> render for the newly posted comment once the Submit happens. What is
> the syntax to say, render a partial once the submit happens?
>
> Thanks,
> Vinod
# app/views/posts/show.rhtml
<%= form_remote_tag :url => {:action => :create_comment, :id =>
@post}
%>
<%= text_area :comment, :body %>
<%= submit_tag ''Submit Comment'' %>
<%= end_form_tag %>
# posts controller
def create_comment
@comment = Comment.new(params[:comment])
@comment.post_id = params[:id]
@comment.save
end
# app/views/posts/create_comment.rjs
page.insert_html :bottom, ''comments'',
:partial => ''comment'', :locals => {:comment
=> comment}
That should be what you need.
--
Posted via http://www.ruby-forum.com/.