Ajax :update used when redirect_to action


#1

This action is called via an Ajax request… with a parameter :update
‘mypropForm’
def modify_prop
@ proposal = Proposal.find_by_id(params[:id])

modify the proposal attribute…

.....

if saved then redirect to proposal list

redirect_to(:action => "list_ proposal", :id => current_user ) and

return if @ proposal.save

if error : redisplay proposal with errors

render :update do |page|
  page.replace_html 'mypropForm', :partial => 'myprop_form'
end

end

when saved, the redirect is performed… but the llist_ proposal action
doesn’t render the full layout as it should… it just render the
partial ! even if the redirect_to request is not an xml_http_request

why this :update parameter is still used anyway to get rid of it in the
redirect ?

thanks to Ajaxian gurus

kad


#2

you really don’t want to mix your rendering like that. and there is no
need to use :update => ‘mypropForm’ in the ajax call in your view, as
you are doing a page.replace_html.

you’re making an ajax request, so instead of redirec_to, you should do

render :update do |page|
if @proposal.save
page.redirect_to …
else
page.replace_html ‘mypropForm’, :partial => ‘myprop_form’
end
end