Skip to content

Instantly share code, notes, and snippets.

@memetican
Last active October 2, 2023 21:03
Show Gist options
  • Save memetican/79a4e587c90106715dc6a4adcb5711c5 to your computer and use it in GitHub Desktop.
Save memetican/79a4e587c90106715dc6a4adcb5711c5 to your computer and use it in GitHub Desktop.
<script>
window.fsAttributes = window.fsAttributes || [];
// Apply the initial input counter value as filter state
window.fsAttributes.push([
'cmsfilter',
(filterInstances) => {
console.log('cmsfilter Successfully loaded!');
const counterButtons = document.querySelectorAll('.fs_inputcounter-1_button');
const counterValue = document.querySelector('.fs_inputcounter-1_input');
counterValue.dispatchEvent(new Event('input', { bubbles: true }));
counterButtons.forEach((button) => {
button.addEventListener('click', () => {
counterValue.dispatchEvent(new Event('input', { bubbles: true }));
});
});
},
]);
// Handle filter updates on increment / decrement
window.fsAttributes.push([
'inputcounter',
(counterInstances) => {
console.log('inputcounter Successfully loaded!');
const counterButtons = document.querySelectorAll('.fs_inputcounter-1_button');
const counterValue = document.querySelector('.fs_inputcounter-1_input');
counterButtons.forEach((button) => {
button.addEventListener('click', () => {
counterValue.dispatchEvent(new Event('input', { bubbles: true }));
});
});
},
]);
</script>
<script>
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'inputcounter',
(counterInstances) => {
console.log('inputcounter Successfully loaded!');
// your code here
},
]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment