From 45154261b7bfb6803efe22e13ebbeab9fc680c20 Mon Sep 17 00:00:00 2001 From: Code Review Videos Date: Wed, 16 Jan 2019 15:50:53 +0000 Subject: [PATCH] Dispatch custom event when user accepts the policy Dispatch a custom event so we can do "interesting things" from elsewhere when the user accepts the policy. In my example I want to redirect the user to the same page, but with a cache buster on the end of the URL: ``` jQuery( document ) .on( "updatedPrivacyPreferences", function() { "use strict"; var current_url = encodeURI( window.location.href ); var qs_concat = current_url.indexOf( "?" ) > -1 ? "&" : "?"; window.location = encodeURI( current_url + qs_concat + "ts=" + new Date().getTime() ); } ); ``` --- src/js/public/gdpr-public.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/public/gdpr-public.js b/src/js/public/gdpr-public.js index b40c44de..965bb9b2 100644 --- a/src/js/public/gdpr-public.js +++ b/src/js/public/gdpr-public.js @@ -116,6 +116,7 @@ $(window).scrollTop(Math.abs( parseInt( scrollDistance, 10 ) ) ); $('.gdpr.gdpr-privacy-preferences .gdpr-wrapper').fadeOut(); $('.gdpr-privacy-bar').fadeOut(); + $( document ).trigger( "updatedPrivacyPreferences" ); } } else { displayNotification( response.data.title, response.data.content );