Let s assume my controller gets a ajax call... I will start the
process to to the appropriate actions...
During the process I discover that the changes are too complex and I
cannot provide the user the response with just an ajax response...
instead I would need a full page fresh...
Unfortunelty, I ve got no idea how to solve this...
Let s assume my controller gets a ajax call... I will start the
process to to the appropriate actions...
During the process I discover that the changes are too complex and I
cannot provide the user the response with just an ajax response...
instead I would need a full page fresh...
Unfortunelty, I ve got no idea how to solve this...
Let s assume my controller gets a ajax call... During the process I discover that the changes are too complex and I
cannot provide the user the response with just an ajax response...instead I would need a full page fresh...
since you have in "page" the object representing your javascript document, you could just send a client-side redirect to that object and the browser would do the rest.
Unfortunately, I don’t believe that will work. From what I’ve seen, what Wes’ solution will do is redraw the entire page inside of the element specified in Ajax.Update, leading to a very odd looking site-in-site effect.
The best way I could think of doing it was to send RJS back that does a simple “document.location = page_url”, forcing the browser to reload the page from scratch.
Unfortunately, I don't believe that will work. From what I've seen, what Wes' solution will do is redraw the entire page inside of the element specified in Ajax.Update, leading to a very odd looking site-in-site effect. The best way I could think of doing it was to send RJS back that does a simple "document.location = page_url", forcing the browser to reload the page from scratch.
if you are not using any "update" parameter when invoking ajax (and if you use update you can change that easily), you can directly do
page.redirect_to whatever
you can do that in the rjs or directly on the controller by using render :update. Behind the scenes it will do domething pretty similar to what you propose, which is changing window.location.href. The advantage is you can use the parameters of redirect_to and you don't need to implement anything at the server side
I could'a sworn that I'd used redirect_to instead of
page.redirect_to.
Anyway, you can do your processing to determine what "too complex"
means, then either render a redirect, render some js in the
controller, or pass it to a .rjs template.
My guess is that you just want cause the entire page to refresh.... so
here is another option...
def my_action
#do stuff
if changes_are_too_complex
render :update do |page|
page.replace_html 'message_to_user_div', '<strong>Reloading
Page...</strong>'
page.call 'location.reload'
end
else
#do other stuff
end
end