Skip to content
Snippets Groups Projects
Commit 2a067e5e authored by Chris Lawton's avatar Chris Lawton
Browse files

move select2 active logic into main js

parent 3fe13e86
No related branches found
No related tags found
No related merge requests found
......@@ -54,13 +54,4 @@ export default () => {
mobileFilterPadding(dropdown);
});
});
// wait for DOM content to load before checking for select2
document.addEventListener('DOMContentLoaded', () => {
// Add active class to select2 checkboxes after page has been filtered
const clearButtons = document.querySelectorAll('.select2-selection__clear');
clearButtons.forEach(clearButton => {
clearButton.parentElement.parentElement.classList.add('is-active');
});
});
};
......@@ -55,6 +55,15 @@ import mobileFilterPadding from './components/mobile-filter-padding';
submissionFilters();
});
// Add active class to select2 checkboxes after page has been filtered
document.addEventListener('DOMContentLoaded', () => {
// If there are clear buttons in the dom, it means the filters have been applied
const clearButtons = document.querySelectorAll('.select2-selection__clear');
clearButtons.forEach(clearButton => {
clearButton.parentElement.parentElement.classList.add('is-active');
});
});
// reset mobile filters if they're open past the tablet breakpoint
$(window).resize(function resize(){
if ($(window).width() < 768) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment