0
我試圖添加一些ajax到我的分頁使用will_paginate gem中指定,我得到了它,我可以看到正確的HTML響應在Firebug,但它實際上並沒有足夠奇怪地渲染新代碼。Rails 3 Will_Paginate隨着Ajax沒有更新部分
這裏是我的簡化代碼:
索引操作
def index
@videos = Video.paginate :page => params[:page], :per_page => per_page
end
index.html.haml
#box_content{:style => "padding: 1em;text-align:center;"}
= render "video
_video.html.haml
- @videos.each do |video|
%iframe{:width=>"200", :height=>"150", :src=>link_src(video.link), :frameborder=>"0", :allowfullscreen =>"true"}
%div.pageinfo
= will_paginate @videos
的application.js
$(function() {
$('.pagination a').live("click", function() {
$.get(this.href, null, null, 'script');
return false;
});
});
index.js.erb的
$('#box_content').html("<%= escape_javascript(render("video")) %>");
無任何響應,當我點擊鏈接will_paginate,如果我看網絡GET響應我看到它確實表明了新的一頁如下:
$('#box_content').html("<iframe allowfullscreen=\'true\' frameborder=\'0\' height=\'150\' src=\'http://www.youtube.com/embed/z52V60aZ7ro\' width=\'200\'><\/iframe>\n<div class=\'pageinfo\'>\n <div class=\"pagination\"><a class=\"previous_page\" rel=\"prev start\" href=\"/?_=1339623038312&page=1\">← Previous<\/a> <a rel=\"prev start\" href=\"/?_=1339623038312&page=1\">1<\/a> <em class=\"current\">2<\/em> <a rel=\"next\" href=\"/?_=1339623038312&page=3\">3<\/a> <a href=\"/?_=1339623038312&page=4\">4<\/a> <a class=\"next_page\" rel=\"next\" href=\"/?_=1339623038312&page=3\">Next →<\/a><\/div>\n<\/div>\n");