sepiariver / recaptchav2

Google's ReCaptcha V2 + V3 for MODX CMS: https://sepiariver.com/modx/recaptchav2-supports-recaptchav3/
https://sepiariver.com/
GNU General Public License v2.0
21 stars 15 forks source link

Trigger loading the script when using JS page transitions #60

Open DESIGNfromWITHIN opened 2 years ago

DESIGNfromWITHIN commented 2 years ago

Hi,

Thansk so much for this plugin, I use it a lot and love it. Recently I have been starting to use BarbaJS combined with MODX, it makes having very nice page transitions easy. The issue now is that the Recaptcha wont 'trigger' when a page transitions using JS.

(I think it is simply not loading the needed JS triggered by the MODX plugin) There is a solution shown here on BarabaJS website: https://barba.js.org/docs/advanced/third-party/#Google-ReCaptcha But I would prefer to keep using the extra.

Do you have any idea how to trigger the recaptcha using recaptchav2 in a Javascript function? I could load that on page transition going to a page with a form.

sepiariver commented 2 years ago

Hey @DESIGNfromWITHIN thanks, it's nice to hear the Extra is useful :)

Barba looks neat!

To trigger Recaptcha on some other event, maybe one of the ideas on this page could help? https://sepiariver.com/modx/a-guide-to-recaptcha-v3-for-modx-cms/

There's an example of an invokation based on a mouse event. It's not a very good solution for a lot of use cases, it's meant as an example. You can use a similar pattern and hook off any other JS event you need to, I think.

Let me know how it goes :)