我下面的分页使用Ajax railscast我的轨道3应用。一切似乎都工作很好,但事实上,previous和明年链接不工作的。
基本上,
看来,previous链接被卡住,即使我点击其他网页上,(当我在用户/显示第1页)
下一个环节工作一次,直到第2页(我不能用它之后)
在我来的数字没有更新为...
我会很高兴地知道,如果有人遇到同样的问题(一个bug?),或者如果我的code是错误的。 我会用分页(〜> 3.0。pre2和jQuery 1.8.10)的microposts依赖于用户的列表。
非常感谢您的帮助!
这里的code:
layout_helper.rb
模块LayoutHelper
高清的JavaScript(*参数)
content_for(:头){javascript_include_tag(*参数)}
结束
结束
users_controller.rb
高清节目
@user = User.find(PARAMS [:ID])
@microposts = @ user.microposts.paginate(:per_page => 10:页=> PARAMS [:页面])
结束
![外媒晒出PSG数据图 多项数据优秀,赛区内战绩仅一负](/d/file/2023/09-16/32b043ab6f93745e20e17a889b521d52.png)
microposts / _micropost.html.erb
...
用户/ show.html.erb
<%JavaScript的分页%>
...
&其中;%= will_paginate @microposts%GT;
&所述;微升的id =feed_items>
&其中;%=渲染@microposts%GT;
< / UL>
用户/ show.js.erb
$(#feed_items)HTML(<%= escape_javascript(渲染@microposts)%>中);
pagination.js
$(文件)。就绪(函数(){
$(分页一)。生活(点击,函数(){
$获得(this.href,NULL,NULL,文字);
返回false;
});
});
解决方案
我建议你看的 http://railscasts.com/episodes/254-pagination-with-kaminari 。
will_paginate不更新使用Rails 3。
I am following the "Pagination with ajax" railscast for my rails 3 application. Everything seems to work great, except the fact that Previous and next links don't work at all.
Basically,
It appears that the previous link is stuck even if I click on other pages, (when I am on the user/show page1)
The "next link" works one time till the page 2 (I can't use it after)
Numbers didn't update when I come to "..."
I would be pleased to know if someone experience the same problem (a bug?) or if my code is wrong. I use will paginate ("~> 3.0.pre2"and jquery 1.8.10) for a list of microposts dependent to users.
Thanks a lot for your help!
here the code:
layout_helper.rb
module LayoutHelper
def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
end
users_controller.rb
def show
@user = User.find(params[:id])
@microposts = @user.microposts.paginate(:per_page => 10, :page => params[:page])
end
microposts/_micropost.html.erb
...
users/show.html.erb
<% javascript "pagination" %>
...
<%= will_paginate @microposts %>
<ul id="feed_items">
<%= render @microposts %>
</ul>
users/show.js.erb
$("#feed_items").html("<%= escape_javascript(render @microposts ) %>");
pagination.js
$(document).ready(function() {
$(".pagination a").live("click", function() {
$.get(this.href, null, null, "script");
return false;
});
});
解决方案
I suggest you look at http://railscasts.com/episodes/254-pagination-with-kaminari .
will_paginate is not updated to work with Rails 3.
相关推荐
最新文章