且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Kaminari使用AJAX,无法分页

更新时间:2023-02-11 18:58:24

我没有看到添加评论的地方,所以这不是真正的答案.

I didn't see a place to add a comment, so this is not a real answer.

是否仅使用AJAX渲染表格?是另一页的一部分吗?还是独立视图?

Do only render the table with AJAX? Is the partial part of another page? Or is a stand alone view?

我遇到了类似的问题(在Kaminari标签页面上,您之前的最后一篇帖子

I had a similar problem (last post before your on the Kaminari tag page link where I had the option to render the table as a partial in a show view or as a separate page. that messed things up. I ended up, like you adding a script tag, but yours in not wrapped in a document ready function, so the page might not be fully loaded. Try.

<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('#paginator').html('<%= escape_javascript(paginate(@pending_requests, :remote => true).to_s) %>');
    $('#requests').html('<%= escape_javascript render (@pending_requests) %>');
  })
</script>