######## Short version:
I need an ajax version of “redirect_to” that either
triggers the browser to do a new XHR (XML-HTTP-Request)
or
triggers rails to behave as if a clean new XHR had come in.
######## Long version:
I have an existing non-ajax rails website. I want to change it in the
way
that I can toggle a switch and the site uses link_to_remote instead of
link_to. This job is done, it works fine. The solution uses .rjs
templates
which make the changes by calling “page.replace_html” for the dynamic
parts
of the page. So far so good.
Now I need an ajax-version for all the “redirect_to”'s in the existing
code.
I see two possible solutions here:
- Tell the browser to do a new XHR
The helper “link_to_remote” produces someting like:
I need an rjs template that, if interpreted by rails and received by the
browser, tells the browser to behave as if the user klicked on the above
“link_to_remote”.
Again with other words: what does an .rjs template look like that tells
the
browser to do an XHR immediately?
- Tell rails to forget everything it did so far and behave as if there
was
a new request x coming in
Is it possible and if how to tell rails: Reset everything you did for
the
current browser request and then handle the following action call as if
it
was produced by a clean new browser request (including everything,
especially the rendering)?
######## Call for help
I followed both ways for hours but didn’t succeed. My knowledge of rails
internals isn’t experienced enough by now. Any help is very much
appreciated.