Last active
May 9, 2025 07:51
-
-
Save JuliaKiselyova/1ecc43f6e6604d353ba7d2fb16329e28 to your computer and use it in GitHub Desktop.
Jet Smart Filter scroll to query ID element after click on filter
This file contains hidden or 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
| document.addEventListener('jet-smart-filters/inited', function(initEvent) { | |
| jQuery(function($) { | |
| window.JetSmartFilters.events.subscribe('ajaxFilters/updated', function(provider, queryId) { | |
| const elementToScrollToId = 'all_ads_listing'; // Specify the ID of the element you want to scroll to | |
| const elementToScrollTo = document.getElementById(elementToScrollToId); | |
| if (elementToScrollTo) { | |
| elementToScrollTo.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start', | |
| }); | |
| } | |
| }); | |
| }); | |
| }); | |
This file contains hidden or 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
| document.addEventListener('jet-smart-filters/inited', function(initEvent) { | |
| jQuery(function($) { | |
| window.JetSmartFilters.events.subscribe('ajaxFilters/updated', function(provider, queryId) { | |
| const filterGroup = window.JetSmartFilters.filterGroups[provider + '/' + queryId]; | |
| if (filterGroup && filterGroup.$provider) { | |
| const widgetElement = filterGroup.$provider[0]; | |
| if (widgetElement) { | |
| widgetElement.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start', | |
| }); | |
| } | |
| } | |
| }); | |
| }); | |
| }); |
This file contains hidden or 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
| document.addEventListener('DOMContentLoaded', function() { | |
| function scrollToJobListing() { | |
| const jobListingElement = document.getElementById('all_ads_listing'); // Specify the ID of the element you want to scroll to | |
| if (jobListingElement) { | |
| jobListingElement.scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| } | |
| } | |
| // Add click event listeners to your filter buttons | |
| const filterButtons = document.querySelectorAll('.jet-radio-list__input, .jet-color-image-list__input, .jet-checkboxes-list__input'); | |
| filterButtons.forEach(function(button) { | |
| button.addEventListener('click', scrollToJobListing); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment