filterrific
filterrific copied to clipboard
AJAX does not work with jQuery 3
Rails 5.1.3
Gemfile:
gem 'jquery-rails'
Without turbolinks
application.coffee:
#= require rails-ujs
#= require jquery3
#= require popper
#= require bootstrap
AJAX does not work. If I replace with this line:
#= require jquery
That AJAX starts working.
Why is this happening?
Second this. Including 2.2.4 jQuery library seems to bring it back up after 3.2.1 fails.
I am also having this issue after upgrading to jQuery 3. This should be fixed as there are security issues with previous versions of JQuery. Anyone want to help me identify the issue and get this fixed?
I also had this problem after upgrading to jQuery 3(no turbolinks installed also).
I just replace
jQuery(document).on('ready page:load', function() {
Filterrific.init();
});
with
jQuery(document).ready(function() {
Filterrific.init();
});
in this file https://github.com/jhund/filterrific/blob/master/app/assets/javascripts/filterrific/filterrific-jquery.js
And it works.
I hope it will help someone
Any new responde for this issue?
I also had this problem after upgrading to jQuery 3(no turbolinks installed also).
I just replace
jQuery(document).on('ready page:load', function() { Filterrific.init(); });
with
jQuery(document).ready(function() { Filterrific.init(); });
in this file https://github.com/jhund/filterrific/blob/master/app/assets/javascripts/filterrific/filterrific-jquery.js
And it works.
I hope it will help someone
Thank you :), works for me with rails 6 and no turbolinks
I'm have the same issue, in combine with will_paginate
. To fix this, I found this code on Web, wich fix too
module WillPaginateHelper
class WillPaginateJSLinkRenderer < WillPaginate::ActionView::LinkRenderer
def prepare(collection, options, template)
options[:params] ||= {}
options[:params]['_'] = nil
super(collection, options, template)
end
protected
def link(text, target, attributes = {})
if target.is_a? Fixnum
attributes[:rel] = rel_value(target)
target = url(target)
end
@template.link_to(target, attributes.merge(remote: true)) do
text.to_s.html_safe
end
end
end
def js_will_paginate(collection, options = {})
will_paginate(collection, options.merge(:renderer => WillPaginateHelper::WillPaginateJSLinkRenderer))
end
end
Then, use js_will_paginate
instead will_paginate
(in Rails 5.2.2)