Media popup trigger some js errors after jQuery upgrade to v1.7 using jquery_update module.

Errors is something like that: Error: cannot call methods on dialog prior to initialization; attempted to call method 'option'

it is happened after the user select an file/image form the media browser popup, the popup is closed and the user continues to scroll on the page

Comments

boyan.borisov’s picture

Issue summary: View changes
StatusFileSize
new1.59 KB

I created a patch.

boyan.borisov’s picture

Status: Active » Needs review
boyan.borisov’s picture

Uploading the same patch without spaces in the file name.

jmuzz’s picture

Category: Feature request » Bug report

#3 works for me. Thanks for this, the error was occuring hundreds of times as the window was scrolled.

ParisLiakos’s picture

  1. +++ b/js/media.popups.js
    @@ -338,6 +338,9 @@ Drupal.media.popups.getPopupIframe = function (src, id, options) {
    +  if(!dialog.is(":visible")) {
    +    return;
    +  }
       if (parent.window.Drupal.overlay && jQuery.isFunction(parent.window.Drupal.overlay.getDisplacement)) {
    

    not exactly sure why it is needed here..maybe because dialog.offset() is called?
    if its needed indeed can we move it to the if below?

  2. +++ b/js/media.popups.js
    @@ -353,6 +356,9 @@ Drupal.media.popups.overlayDisplace = function (dialog) {
     Drupal.media.popups.sizeDialog = function (dialogElement) {
    +  if(!dialogElement.is(":visible")) {
    +    return;
    +  }
    
    @@ -373,6 +379,9 @@ Drupal.media.popups.sizeDialog = function (dialogElement) {
     Drupal.media.popups.resizeDialog = function (dialogElement) {
       $(window).resize(function() {
    +    if(!dialogElement.is(":visible")) {
    +      return;
    +    }
         Drupal.media.popups.sizeDialog(dialogElement);
    

    Do we need to add the check in both those spots?
    I think just in the sizeDialog() would be enough.

ParisLiakos’s picture

StatusFileSize
new875 bytes

so i removed the check from Drupal.media.popups.overlayDisplace and Drupal.media.popups.resizeDialog

moonray’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #6 fixes the issues for me.

  • Commit 221bb20 on 7.x-2.x by aaron:
    Issue #2184475 by ParisLiakos, boyan.borisov: Media popup trigger some...
aaron’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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