Skip to main content

JavaScript hooks and events

Overview​

WPEnhanced Ajax Filter Blocks updates the Archive Loop over AJAX. Front-end scripts that initialize UI inside loop items must re-run after each update. The plugin exposes a jQuery event and related globals for this purpose.

This reference covers practical patterns—not every internal function, which may change between releases.

Primary event: divi_filter_completed​

After a filter request completes and loop HTML is applied, the plugin triggers:

jQuery.event.trigger({ type: 'divi_filter_completed' });

Listen with:

jQuery(document).on('divi_filter_completed', function () {
// Loop DOM is updated; safe to re-init third-party scripts
});

When it fires​

  • Standard filter changes (taxonomy, meta, price, search, etc.)
  • Pagination within the filtered loop
  • Load More and infinite scroll append operations (Pro)
  • Reset filters (when the loop re-renders)

When to use it​

Use caseExample
Re-init galleriesLightbox, PhotoSwipe, theme gallery
Lazy loadIntersection Observer on new images
WooCommercewc_variation_form() on new product cards
AnalyticsTrack filter interactions after DOM settle
Custom carouselsSwiper / Slick on injected slides

See also Run JavaScript after AJAX.

Registration best practices​

(function ($) {
function onFilterCompleted() {
// Your logic
}

$(function () {
$(document).on('divi_filter_completed', onFilterCompleted);
});
})(jQuery);
  • Register once on document ready.
  • Avoid heavy synchronous work—defer large DOM scans.
  • Guard third-party calls with typeof checks if optional plugins may be inactive.

The plugin may expose helper functions on window for compatibility with Divi Ajax Filter-derived codebases, including:

GlobalPurpose
divi_filter_paramsUpdate selected-filter chip UI when customizing filter parameter display
divi_filter_params_arrayBatch chip updates
handle_conditional_fieldsRe-evaluate conditional filter visibility (Pro)
show_hide_resetToggle reset button visibility after apply

Rely on divi_filter_completed for most integrations; use globals only when extending chip UI or conditional filters.

DOM selectors​

Filter UI commonly uses these containers (useful for scoped re-init):

SelectorElement
.divi_filter_moduleFilter Posts wrapper
#divi_filterMain filter root ID
.filter-param-itemActive filter chips
.search_filter_contIndividual filter item container

Loop output is replaced inside the Archive Loop block wrapper—scope queries to that container when possible.

No native CustomEvent (currently)​

The completion signal is a jQuery event on document, not a standard window CustomEvent. Use jQuery or bridge manually:

jQuery(document).on('divi_filter_completed', function () {
window.dispatchEvent(new CustomEvent('ajaxFilterBlocksCompleted'));
});

Debugging​

Enable browser Network tab to confirm REST responses return 200. Use Console to log inside your divi_filter_completed handler and verify it runs on each filter change.

What's next​