Rails 3.1 中的 Ajaxify will_paginate
我正在尝试 ajaxify will_paginate 结果在 Rails 3.1 中。我已经浏览了 Railscasts Episode #174 的示例,但它不适用于 Rails 3.1。
有没有一种简单的方法可以在rails3.1中ajaxify will_paginate结果?
这是用于加载用户部分的index.js.erb代码(该文件位于app/views/users文件夹中) $('#test').html("<%= escape_javascript(render(@users)) %>"
);
这是我的 pagination.js 代码(该文件位于 app/assets/javascripts 中)
$(function() {
$(".users a").live("click", function() {
$.get(this.href, null, null, "script");
return false;
});
});
我正在使用 will_paginate 这两个文件都已加载并且我已经对其进行了测试。
对我在哪里犯错误有帮助吗?
谢谢,
I am trying to ajaxify will_paginate result in rails 3.1. I have gone through the example of railscasts episode #174 but it is not working for rails 3.1.
Is there a simple way to ajaxify will_paginate result in rails3.1?
Here is index.js.erb code for loading the user partial (this file is in app/views/users folder)$('#test').html("<%= escape_javascript(render(@users)) %>"
);
Here is my pagination.js code (this file is in app/assets/javascripts)
$(function() {
$(".users a").live("click", function() {
$.get(this.href, null, null, "script");
return false;
});
});
I am using will_paginate both the files are getting loaded and I have tested for it.
Any help on where I am making the mistake?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 pagination.js 中的行:
$(".users a").live("click", function() {
替换为
$(".pagination a").live("click", function() {
然后只需确保您的 index.js.erb 命名正确。例如,如果您在查看 show.html.erb,您的脚本必须命名为 show.js.erb
replace the line in pagination.js:
$(".users a").live("click", function() {
with
$(".pagination a").live("click", function() {
Then just make sure your index.js.erb is named correctly. For example, if you're using pagination inside the view show.html.erb, your script has to be named show.js.erb