Created
March 28, 2018 16:31
-
-
Save mgibbs189/f3b4fc68e042770a537215ccf39cb4a7 to your computer and use it in GitHub Desktop.
Manually replace sort box with fSelect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="path/to/fSelect.css" rel="stylesheet" type="text/css"> | |
<script src="path/to/fSelect.js"> | |
<script> | |
(function($) { | |
$(document).on('facetwp-loaded', function() { | |
$('.facetwp-sort-select').fSelect(); | |
}); | |
})(jQuery); | |
</script> |
Maybe the
fs:closed
event that fires the autoload in front-facets.js can only autoload if that fselect is bound to a facet?
@jackgregory that's a good suggestion, would make sense to make sure the fSelect has a parent facetwp-facet
element before firing :)
E.g.
$(document).on('fs:closed', function(e, wrap) {
var is_facet = $(wrap).closest('.facetwp-facet').length > 0;
if (is_facet && ! wrap.classList.contains('multiple')) {
FWP.autoload();
}
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mgibbs189 this works but fires
FWP.autoload();
twice on the sort change event and thefs:closed
event. This can be fixed by removing the change event and then adding it again withoutFWP.autoload()
.Better way to handle this? Maybe the
fs:closed
event that fires the autoload in front-facets.js can only autoload if that fselect is bound to a facet?