jhund / filterrific

Filterrific is a Rails Engine plugin that makes it easy to filter, search, and sort your ActiveRecord lists.
http://filterrific.clearcove.ca
MIT License
910 stars 124 forks source link

AJAX does not work with jQuery 3 #141

Open afuno opened 7 years ago

afuno commented 7 years ago

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?

vzelenko commented 7 years ago

Second this. Including 2.2.4 jQuery library seems to bring it back up after 3.2.1 fails.

enderwiggens commented 3 years ago

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?

mateo9 commented 3 years ago

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

aweiand commented 3 years ago

Any new responde for this issue?

pramod-wick commented 3 years ago

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

aweiand commented 3 years ago

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)