Problem/Motivation

"Error: cannot call methods on dialog prior to initialization; attempted to call method 'option'" happens when you close an #ajax dialog and scroll in the page.

Steps to reproduce:

  1. Enable views UI.
  2. Edit Content view.
  3. Click the Add field button.
  4. Close the dialog, using the top right X button.
  5. Scroll in the page.
  6. See your browser Javascript console.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

penyaskito created an issue. See original summary.

nod_’s picture

Right so you shouldn't use the X. It was removed at one point because we had problems making detachBehaviors run upon closing. The error you're seeing basically.

penyaskito’s picture

If we shouldn't use the X, should we remove it then?

droplet’s picture

FileSize
1.62 KB

Shouldn't it work this way? Drupal.dialog is a bit mess

droplet’s picture

Status: Active » Needs work
FileSize
1.48 KB

Look into this issue again.

+++ b/core/misc/dialog/dialog.js
@@ -31,6 +31,7 @@
     close: function (event) {
+      Drupal.dialog(event.target).close();
       Drupal.detachBehaviors(event.target, null, 'unload');

have to make sure `close` method in Drupal.dialog to be called.

wahono77’s picture

I use patch from @droplet and it's OK now.

jastraat’s picture

This same error occurs related to editing content with the core WYSIWYG.

1. Click to add a basic page.
2. Click the image icon in the WYSIWYG. A dialog pops up.
3. Close the dialog, using the top right X button.
4. Scroll in the page.
5. See your browser Javascript console.

droplet’s picture

the patch should be fixed it globally, please test :)

droplet’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: 2559241-5.patch, failed testing.

droplet’s picture

Component: ajax system » javascript
Status: Needs work » Needs review
FileSize
1.33 KB
tic2000’s picture

There is any actual point in moving all that code to the start of Drupal.dialog?

droplet’s picture

var hoisting, more closing to Drupal JS Code Standard.

+++ b/core/misc/dialog/dialog.js
@@ -60,6 +61,18 @@
+      returnValue: null,

actually it has one line change from `undef` to `null`

tic2000’s picture

Status: Needs review » Reviewed & tested by the community

I applied the patch and it fixes the issue when scrolling.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I've confirmed that the patch fixes the bug but...

+++ b/core/misc/dialog/dialog.js
@@ -60,6 +61,18 @@
+      returnValue: null,

@@ -78,20 +91,6 @@
-    var undef;
...
-      returnValue: undef,

This is an API change. We shouldn't be making unnecessary API changes in bug fixes. Even if the current API is against our coding standards.

tic2000’s picture

Status: Needs work » Needs review
FileSize
1.35 KB

Changed as per #15

tic2000’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs review

@tic2000 thanks for making the changes - really someone else should come in and rtbc them. People can and do disagree with me :)

swentel’s picture

Status: Needs review » Reviewed & tested by the community

Good to go.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 393d5b1 and pushed to 8.0.x and 8.1.x. Thanks!

  • alexpott committed 867bf59 on 8.1.x
    Issue #2559241 by droplet, tic2000: Closing an #ajax dialog triggers...

  • alexpott committed 393d5b1 on
    Issue #2559241 by droplet, tic2000: Closing an #ajax dialog triggers...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.