I've written an .rjs template to update more than one page element at once. It seems to work perfectly when I call it using a link on the page, i.e.:
link_to_remote( image_tag("button_add.gif"), :url =>{:action => 'side_comment_return', :id => i, :article_id => @article.id } )
But when I attempt to call that same .rjs template from an action that responds to a form post, i.e.:
def create_side_comment Article.find(params[:id]).comments.create(params[:comment]) flash[:notice] = "Added comment." redirect_to (:action => 'side_comment_return', :id => params[:paragraph_id], :article_id => params[:id] ) end
it spews all of the javascript onto the area of the page that i am trying to update, rather than simply rendering the html like I expect, like:
try { Element.update("side_comment3", "\ntest -test
\n"); Element.update("add_comment_button3", "\"Add"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"side_comment3\", \"\ntest -test
\n\");\nElement.update(\"add_comment_button3\", \"\\"Add\");'); throw e }
Am I using the redirect_to method inappropriately? Thanks for any help, this is the first time I've posted a question here, and I appreciate your time.