Javascript 刷新Kaminari中当前页面的数据
我正在利用图书馆对一些记录进行分页。这些是我使用的文件 views/users/show.html.hamlJavascript 刷新Kaminari中当前页面的数据,javascript,jquery,ruby-on-rails,ajax,kaminari,Javascript,Jquery,Ruby On Rails,Ajax,Kaminari,我正在利用图书馆对一些记录进行分页。这些是我使用的文件 views/users/show.html.haml %table.table.table-striped %thead %tr %th Lead ID %th Date/Time %th Property Address %th Connection %th Response Time %tbody#showings = render '/showings/list', showings:
%table.table.table-striped
%thead
%tr
%th Lead ID
%th Date/Time
%th Property Address
%th Connection
%th Response Time
%tbody#showings
= render '/showings/list', showings: @showings
#paginator
= paginate @showings, remote: true, params: {controller: "showings", action: 'index'}
- showings.each do |showing|
%tr
%td= showing.id
%td= showing.created_at_formated
%td= showing.address
%td= showing.connected?
%td= showing.reply_time_mins_secs
查看/显示/_list.html.haml
%table.table.table-striped
%thead
%tr
%th Lead ID
%th Date/Time
%th Property Address
%th Connection
%th Response Time
%tbody#showings
= render '/showings/list', showings: @showings
#paginator
= paginate @showings, remote: true, params: {controller: "showings", action: 'index'}
- showings.each do |showing|
%tr
%td= showing.id
%td= showing.created_at_formated
%td= showing.address
%td= showing.connected?
%td= showing.reply_time_mins_secs
显示控制器
class ShowingsController < ApplicationController
def index
@showings = Showing.all.page(current_page)
end
end
class ShowingsController
查看/展示/index.js.erb
$('#paginator').html('<%= escape_javascript(paginate(@showings, :remote => true).to_s) %>');
$('#showings').html('<%= escape_javascript(render "/showings/list", showings: @showings) %>');
$('#paginator').html('true.to_s)%>');
$('#showings').html('');
因此,我需要能够刷新当前显示页面的数据。是否可以使用AJAX或JQuery刷新de数据?仅限“分页器”和“显示”部分。当前,当我按下当前页面的按钮时,什么也没有发生。是否尝试添加参数[:page]
=paginate@showings,remote:true,params:{controller:“showings”,action:'index',page:params[:page]}
尝试添加page参数,但我不知道如何解决此问题。我正在考虑使用类似$(“#paginator.active a”)的东西;您是否尝试添加参数[:page]=paginate@showings,remote:true,params:{controller:“showings”,action:'index',page:params[:page]}
尝试添加page参数,但我不知道如何解决此问题。我正在考虑使用类似$(“#paginator.active a”)的东西;