简体   繁体   English

Rails:使用AJAX响应重定向到上一页

[英]Rails : Redirect to previous page with AJAX Response

I have this page where I have a form_remote_tag that returns an AJAX, paginated response : 我在此页面上有一个form_remote_tag返回一个AJAX分页响应:

<% form_remote_tag :url => searchs_path, :html => {:id => "search_form"} do %>

<!-- Blah -->

<% end %> 

Results are printed in another div and point to totally different views. 结果将打印在另一个div中,并指向完全不同的视图。 Now my main concern is not about browsing through the paginated results. 现在,我主要关心的不是浏览分页结果。 My objective is that once I click on a result thus going to a different URL, I can just get back to the main search form filled with the previous AJAX response . 我的目标是,一旦我点击一个结果从而转到另一个URL,我就可以回到填充先前AJAX响应的主搜索表单。

I tried using the HTML5 history API but it looks like it just helps browsing through the one-pager (which is not top-priority for me). 我尝试使用HTML5历史记录API,但看起来它仅有助于浏览一页(对我而言不是最优先的)。 I am thinking about page caching though it might be an overkill. 我正在考虑页面缓存,尽管这可能是一个过高的选择。 Any thoughts on this ? 有什么想法吗?

最终设法通过localStorage API存储AJAX DOM数据来解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM