ajax 调用后替换 will_paginate 链接
我正在开发 Ruby on Rails 应用程序,我的问题是我对帖子的所有评论进行了分页并完美显示,但是当用户通过 ajax 保存新评论时,我将所有内容替换为部分内容新内容(包括 will_paginate @comments),链接的 url 更改为保存评论的操作的 url,我不知道如何使它们正确链接。
我尝试使用 <%= will_paginate @comments, :params =>; {:控制器=> '帖子', :action => 'show_outside_comments' %>
但我得到了相同的结果。
非常感谢您的帮助!
I'm working on a Ruby on Rails aplicattion, my problem is that I have all the comments of a post paginated and showed perfectly, but when an user saves a new comment via ajax, and I replace all the content with the partial with the new content(including the will_paginate @comments), the urls of the links change to the url of the action that saves the comments and i don't know how to do to make them link correctly.
I tried with <%= will_paginate @comments, :params => {:controller => 'posts', :action => 'show_outside_comments' %>
But I get the same results.
Thank you very much for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您研究过这里描述的 ajax 方法吗?
http://railscasts.com/episodes/174-pagination-with-ajax
Have you looked into the ajax methods described here?
http://railscasts.com/episodes/174-pagination-with-ajax
您可以执行 javascript 代码来更新链接,
像这样的东西:
you can execute javascript code to update the links,
something like:
假设您想用当前路径名替换“/comments”。
Assuming you want to replace `/comments' with the current pathname.