Open djpremier opened 1 year ago
Could be related to https://github.com/jhund/filterrific/issues/220? Try adding an empty div with a .filterrific_spinner class.
I added this to my application.js and it fixed it. If you are using select2 you have jquery anyway so it shouldn't be a problem using jquery here. It is just replacing with what the code was before in filterrific.
I'm going to try figure out what the issue is.
Filterrific.init = function() {
$('#filterrific_filter').on(
"change",
":input:not(.filterrific-periodically-observed)",
Filterrific.submitFilterForm
);
Filterrific.observe_field(
".filterrific-periodically-observed",
0.5,
Filterrific.submitFilterForm
);
};
jQuery(document).ready(Filterrific.init);
jQuery(document).on('page:load', Filterrific.init);
I also have to replace the submitFilterForm method.
Filterrific.submitFilterForm = function(){
var form = $(this).parents("form"),
url = form.attr("action");
// turn on spinner
$('.filterrific_spinner').show();
// Submit ajax request
$.ajax({
url: url,
data: form.serialize(),
type: 'GET',
dataType: 'script'
}).done(function( msg ) {
$('.filterrific_spinner').hide();
});
};
This is mostly a select2 issue. This is a very old library whose developers decided for some dumb reason that it won't trigger the standard change
event when the select, well, changes.
Here's more info and a workaround: https://stackoverflow.com/a/77871613/1102840
After change of jQuery to Vanilla JS, the change in fields that use Select2 don't trigger filteriffic search.