When a visitor uses a filter, the posts widget reloads its items with AJAX. To run your own JavaScript after the items are reloaded, for example to start a slider or an animation on the new items, listen to the events below.
Find the Grid
The events run on the grid: the element with the uc-filterable-grid class inside your posts widget. To select it easily, give the widget a CSS ID in Elementor (Advanced > CSS ID), for example my-grid. Then select the grid with #my-grid .uc-filterable-grid.
Add your code in a <script> tag on the page, for example in an HTML widget, and wrap it in jQuery(function(){ ... }); so it runs when the page is ready.
After the Grid Is Refreshed
The uc_ajax_refreshed event runs on the grid after the new items are added:
jQuery(function(){
jQuery("#my-grid .uc-filterable-grid").on("uc_ajax_refreshed", function(){
// your code here
});
});
Listen on the Page Body
The uc_ajax_refreshed_body event runs on the page body after any grid is refreshed. This is easier when the page has several grids. The second argument is the grid that was refreshed:
jQuery(function(){
jQuery("body").on("uc_ajax_refreshed_body", function(event, objGrid){
// objGrid is the grid that was refreshed
});
});
Before the Grid Is Refreshed
The uc_before_ajax_refresh event runs on the grid just before it sends the request for new items:
jQuery(function(){
jQuery("#my-grid .uc-filterable-grid").on("uc_before_ajax_refresh", function(){
// your code here
});
});