Skip to content

Instantly share code, notes, and snippets.

@JuliaKiselyova
Last active May 9, 2025 07:51
Show Gist options
  • Select an option

  • Save JuliaKiselyova/1ecc43f6e6604d353ba7d2fb16329e28 to your computer and use it in GitHub Desktop.

Select an option

Save JuliaKiselyova/1ecc43f6e6604d353ba7d2fb16329e28 to your computer and use it in GitHub Desktop.
Jet Smart Filter scroll to query ID element after click on filter
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',
});
}
});
});
});
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',
});
}
}
});
});
});
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