drupalSettings not updated on rendering form in Ajax

Created on 23 March 2021, over 3 years ago
Updated 4 March 2024, 7 months ago

Problem/Motivation

drupalSettings variable is not updating if we render a form with Ajax. So it is getting "Cannot set Property human of undefined" error

Steps to reproduce

1. Enable Antibot to a web form (any form)
2. Render the form with an ajax request
3. and Submit the form, you will get Javascript not enabled in the browser error (even if it is enabled)
Before the on the form load, getting js error as mentioned above.

Proposed resolution

When we render an element through ajax we will call attachBehaviors with the new elements and settings. So in the antibot.js attach function should receive new settings and use it as a drupalSettings.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India leopathu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States joegraduate Arizona, USA

    We're still using this patch on a large number of sites without any issues (see #15).

  • 🇨🇦Canada danrod Ottawa

    Thanks for the patch !

    I tested this and works as expected, I was able to do a webform submission (the webform was set to use an AJAX request for all submissions) and worked fine, no errors seen in the browser console.

    There are some issues when running the tests on this module (mentioned in the comment #6), but I'll address these issues in a separate issue: https://www.drupal.org/project/antibot/issues/3392673 🐛 Fatal error when running tests Needs work

    I'll commit this to the 2.0.x branch.

    Moving this to "Fixed"

  • Status changed to Fixed 7 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024