ABPrime ABPrime - 2 years ago 183
Javascript Question

kaminari paginate via ajax ,remote = true is not affect on view in rails 3

Hello i am using kaminari gem for pagination and i want to do paginatation via ajax .


= render :partial => 'anything/anything_lists', collection: @anything_upcoming, as: :anything_schedule
= paginate @anything_upcoming, :remote => true, :param_name => "anything_upcoming_page"


$('#abc').html('#{escape_javascript render(partial: "anything/anything_lists")}');
$('#paginator').html('#{escape_javascript(paginate(@anything_upcoming, :remote => true, :param_name => "anything_upcoming_page").to_s)}');

controller file:

@anything_upcoming = AnythingSchedule.anything_upcoming.page(params[:anything_upcoming_page]).per(Settings.pagination.per_page)

respond_to do |format|

view source shows data-remote = true but log shows Website::EventsController#index as HTML.
so what i am missing here.

Edit: i am doing some experiment on js file and i convert index.js.haml to index.js.erb and only one time i get ajax request and also shows calling JS on logs . and i redo again then as usual not get ajax request .

Final Edit

//= require jquery
//= require jquery_ujs
//= require ckeditor-jquery
//= require bootstrap.min
//= require bootstrap-datepicker.min
//= require bootstrap-timepicker.min
//= require chosen.jquery.min
//= require jquery.popupoverlay
//= require common
//= require ace-elements.min
//= require registrations
//= require courses
//= require instructors
//= require jsapi
//= require donation
//= require workshops
//= require nav_settings_dropdown
//= require events
//= require event_schedules
//= require manage_home
//= require jquery.blockUI
//= require rails

Gem file

gem 'rails', '3.2.17'
gem 'haml'
gem 'haml-rails'
gem "rails_config", "~> 0.3.3"

group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-fileupload-rails'
gem 'jammit'

gem 'jquery-rails'
gem "kaminari", "~> 0.14.1"

Answer Source

you must have forgotten to include the application.js in your layout file


you are using another js or layout then the default one. Please check this


The syntax for the pagination is correct

= paginate @anything_upcoming, :remote => true, :param_name => "anything_upcoming_page"

you have also included jquery-rails gem and also included the libraries in application.js

and you are saying data-remote = true is applying to the element. So the only problem i guess left is above one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download