From 06368668980933b9f97490ae153ee622c7b9b388 Mon Sep 17 00:00:00 2001 From: codepuncher Date: Fri, 22 Nov 2024 16:41:16 +0000 Subject: [PATCH] fix: support Gravity Perks Cache Buster --- public/js/gf-giftaid-field-frontend.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/js/gf-giftaid-field-frontend.js b/public/js/gf-giftaid-field-frontend.js index 01f9801..b2b6aac 100644 --- a/public/js/gf-giftaid-field-frontend.js +++ b/public/js/gf-giftaid-field-frontend.js @@ -1,10 +1,12 @@ -document.addEventListener('DOMContentLoaded', initGiftAid); +if (window.jQuery) { + window.jQuery(document).on('gform_post_render', initGiftAid); +} /** * Updates the gift aid display, based on a chosen field changing. */ -function initGiftAid() { - const gravityForm = document.querySelector('.gform_wrapper'); +function initGiftAid(_, form_id) { + const gravityForm = document.getElementById('gform_wrapper_' + form_id); if (!(gravityForm instanceof HTMLElement)) { return; }