Commit cd3230a5 authored by webchick's avatar webchick

Issue #1636992 follow-up by nod_, droplet: Follow-up: form.js' formUpdated...

Issue #1636992 follow-up by nod_, droplet: Follow-up: form.js' formUpdated event is unreliable/incomplete.
parent 3b6460a7
......@@ -147,11 +147,8 @@ Drupal.behaviors.formUpdated = {
attach: function (context) {
var $context = $(context);
var contextIsForm = $context.is('form');
var $forms = $context.find('form').once('form-updated');
var $forms = (contextIsForm ? $context : $context.find('form')).once('form-updated');
if (contextIsForm) {
$forms = $context;
}
if ($forms.length) {
// Initialize form behaviors, use $.makeArray to be able to use native
......@@ -180,8 +177,9 @@ Drupal.behaviors.formUpdated = {
},
detach: function (context, settings, trigger) {
var $context = $(context);
var contextIsForm = $context.is('form');
if (trigger === 'unload') {
var $forms = $context.find('form').removeOnce('form-updated');
var $forms = (contextIsForm ? $context : $context.find('form')).removeOnce('form-updated');
if ($forms.length) {
$.makeArray($forms).forEach(function (form) {
form.removeAttribute('data-drupal-form-fields');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment