We ran into this when a module tried to run attachBehaviors earlier in the page load.

CommentFileSizeAuthor
#1 1099794_context.patch3.12 KBJacobSingh

Comments

JacobSingh’s picture

Status: Active » Needs review
StatusFileSize
new3.12 KB
james.elliott’s picture

Status: Needs review » Needs work

This bit makes sense

+    if (!$('#form-builder', context).length) {
+      // The interface is not ready yet or non-existant.
+      return;
+    }

But I'm quite sure that the other parts where you've added context were specifically designed not to have it. I think it is because the drag and drop interactions specifically need to be reset when a new form element is added.

effulgentsia’s picture

+++ webform_alt_ui.js	21 Mar 2011 07:02:38 -0000
@@ -7,6 +7,11 @@
+    if (!$('#form-builder', context).length) {
+      // The interface is not ready yet or non-existant.
+      return;
+    }
+

Even this part isn't quite right, because the behavior is intended to run for an AJAX returned context that's *inside* #form-builder, and this if statement prevents that.

The behavior code is fragile, however, and can benefit from some cleanup to use context and .once() properly, so leaving this issue open. In the meantime, #1100852: JS error when behavior runs on context unrelated to form builder contains one small addition to be more robust for the use-case that started this issue.