Hello, I am currently utilizing the kaminari gem for pagination and I would like to implement pagination through ajax.
index.html.haml
#abc
= render :partial => 'anything/anything_lists', collection: @anything_upcoming, as: :anything_schedule
#paginator
= paginate @anything_upcoming, :remote => true, :param_name => "anything_upcoming_page"
index.js.haml
$('#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)}');
In the controller file:
@anything_upcoming = AnythingSchedule.anything_upcoming.page(params[:anything_upcoming_page]).per(Settings.pagination.per_page)
respond_to do |format|
format.js
format.html
end
The view source displays data-remote = true, however, the log shows Website::EventsController#index as HTML. It seems like something is missing here.
Edit: I have been experimenting with the JavaScript file and converted index.js.haml to index.js.erb. Initially, I received an ajax request and it showed JS being called in the logs. However, after redoing it, I did not receive the ajax request.
Final Edit application.js
//= 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'
end
gem 'jquery-rails'
gem "kaminari", "~> 0.14.1"