Created
June 14, 2025 02:14
-
-
Save VictorPietro/9cf8455123f06b7ea287c04f6fdd11b3 to your computer and use it in GitHub Desktop.
Add custom loader to listing grid when filtering using AJAX
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
| /* | |
| 1. Add a container with class .lottie-loader | |
| 2. Inside the container, add a Lottie/image and the HTML below | |
| 3. Change "#grid-guias" to the ID of the listing grid that is being filtered | |
| */ | |
| <style> | |
| .lottie-loader { | |
| display: none; | |
| } | |
| </style> | |
| <script> | |
| jQuery(function($) { | |
| // Waits for the DOM to be ready and JetSmartFilters to be initialized | |
| var $spinnerContainer = $('.lottie-loader'); | |
| var $listingContainer = $('#grid-guias'); | |
| if ($spinnerContainer.length && $listingContainer.length) { | |
| // Event triggered when loading starts | |
| window.JetSmartFilters.events.subscribe('ajaxFilters/start-loading', function() { | |
| $spinnerContainer.css('display', 'flex'); | |
| $listingContainer.css('display', 'none'); | |
| }); | |
| // Event triggered when loading ends | |
| window.JetSmartFilters.events.subscribe('ajaxFilters/end-loading', function() { | |
| $spinnerContainer.css('display', 'none'); | |
| $listingContainer.css('display', 'flex'); | |
| }); | |
| } | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment