Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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:
- Enable views UI.
- Edit Content view.
- Click the Add field button.
- Close the dialog, using the top right X button.
- Scroll in the page.
- See your browser Javascript console.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#16 | 2559241-16.patch | 1.35 KB | tic2000 |
#11 | 2559241-11-fixing-dialog-errors.patch | 1.33 KB | droplet |
#5 | 2559241-5.patch | 1.48 KB | droplet |
|
Comments
Comment #2
nod_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.
Comment #3
penyaskitoIf we shouldn't use the X, should we remove it then?
Comment #4
droplet CreditAttribution: droplet commentedShouldn't it work this way? Drupal.dialog is a bit mess
Comment #5
droplet CreditAttribution: droplet commentedLook into this issue again.
have to make sure `close` method in Drupal.dialog to be called.
Comment #6
wahono77 CreditAttribution: wahono77 commentedI use patch from @droplet and it's OK now.
Comment #7
jastraat CreditAttribution: jastraat at Technivant commentedThis 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.
Comment #8
droplet CreditAttribution: droplet commentedthe patch should be fixed it globally, please test :)
Comment #9
droplet CreditAttribution: droplet commentedComment #11
droplet CreditAttribution: droplet commentedComment #12
tic2000 CreditAttribution: tic2000 at Intellix commentedThere is any actual point in moving all that code to the start of Drupal.dialog?
Comment #13
droplet CreditAttribution: droplet commentedvar hoisting, more closing to Drupal JS Code Standard.
actually it has one line change from `undef` to `null`
Comment #14
tic2000 CreditAttribution: tic2000 at Intellix commentedI applied the patch and it fixes the issue when scrolling.
Comment #15
alexpottI've confirmed that the patch fixes the bug but...
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.
Comment #16
tic2000 CreditAttribution: tic2000 at Intellix commentedChanged as per #15
Comment #17
tic2000 CreditAttribution: tic2000 at Intellix commentedComment #18
alexpott@tic2000 thanks for making the changes - really someone else should come in and rtbc them. People can and do disagree with me :)
Comment #19
swentel CreditAttribution: swentel commentedGood to go.
Comment #20
alexpottCommitted 393d5b1 and pushed to 8.0.x and 8.1.x. Thanks!