diff --git a/core/misc/ajax.js b/core/misc/ajax.js index f8a1cb0..d5fb9ba 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -714,7 +714,7 @@ // attachBehaviors() called on the new content from processing the response // commands is not sufficient, because behaviors from the entire form need // to be reattached. - if (this.$form) { + if (this.$form && this.$form.parents('html').length > 0) { var settings = this.settings || drupalSettings; Drupal.attachBehaviors(this.$form.get(0), settings); } @@ -776,7 +776,7 @@ // Re-enable the element. $(this.element).prop('disabled', false); // Reattach behaviors, if they were detached in beforeSerialize(). - if (this.$form) { + if (this.$form && this.$form.parents('html').length > 0) { var settings = response.settings || this.settings || drupalSettings; Drupal.attachBehaviors(this.$form.get(0), settings); }