Need Help: WP Gridbuilder Facet Doesn’t Load on First PJAX Page Load

Hey,

@Daniele I could use some help with a WP Gridbuilder facet that just won’t load on the first page load when PJAX is enabled in Bricksforge. Right now, the facet only appears after an additional reload, and we’ve tried several things but still no luck getting it to show right away.

Setup

Facet class: .wpgb-facet-2

Bricksforge settings: PJAX page transitions are enabled.

Problem: Facet only loads after a page reload, instead of showing up on the first load.

What We’ve Tried So Far

  1. Direct Initialization on swup:contentReplaced Event:

• Tried adding document.addEventListener(“swup:contentReplaced”, initializeFacet); and triggering on DOMContentLoaded.

Result: Still doesn’t load on the first attempt—only after a reload.

  1. Console Errors:

• We’re seeing Promise returned from handler for synchronous hook ‘link:self’. Swup will not wait for it to resolve. with every page transition.

• It seems like Swup might not be reloading the facet properly, or there’s a timing issue.

  1. Slider Script Works, but Facet Remains Invisible:

• The slider_script(); for other content works fine, but the WP Gridbuilder facet only shows up after a manual page reload.

Feedback from WP Gridbuilder Support

Their support team mentioned this:

“Unfortunately, making the plugin work with PJAX requires more than simply entering some JS functions. This is mainly because if you load a page which does not have a grid or facet, the scripts will be missing as they are only enqueued when necessary…”

It sounds like WP Gridbuilder can’t automatically reload the facet when pages load via PJAX. Daniele (or anyone), do you have any ideas on how to get the facet to show up correctly on the first load? Or maybe there’s a trick for resolving the context issue they mentioned?

Thanks so much in advance for any ideas! :blush:

Making Pjax compatible with WPGridBuilder sounds like a tough job. I think this will require a developer with advanced knowledge. Maybe as a tip: instead of using your own event listeners, use the code boxes that you can find in the Bricksforge settings under ‘Page Transitions’. These are directly linked to the correct instance of Swup. Maybe you’ll get further with that :slight_smile: