I recently upgraded to 1.3 and received the following error: Cannot read property 'height' of undefined. Was led to the following code snippet:

Drupal.behaviors.JiraIssueCollector = {
  attach: function(context, settings) {
    // Use ajax() instead of getScript() as this allows cache to be enabled.
    // This is preferable for performance reasons. The JIRA Issue Collector
    // script should not change much.
    if (typeof settings.jiraIssueCollector != 'undefined') {
      jQuery.ajax({
        url: settings.jiraIssueCollector.url,
        type: "get",
        dataType: "script",
        cache: true,
        success: function() {
          // If we use a issue collector located at the top of the page
          // ("Prominent" style) and show a toolbar, then the toolbar will be
          // positioned over the issue collector button. Adjust the position so
          // it shows below the toolbar.
          // We cannot set attributes directly on the element as we do not know
          // when it will be available.
          // .atlwdg-TOP class ensures we affect only issue collectors with the
          // prominent style.
          $('<style>')
            .attr("type", "text/css")
            .html('body.toolbar .atlwdg-TOP { top: ' + <strong>Drupal.toolbar.height() + 'px; }')</strong>
            .appendTo('head');
        }
      });
    }
  }
};

Reverted to the JS from 1.2 and the JIRA tab was no longer visible.

CommentFileSizeAuthor
#4 js_error_cannot_read-2653580-4.patch843 bytesmdeltito
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adambehnke created an issue. See original summary.

adixb’s picture

Issue summary: View changes
adixb’s picture

I commented out this section and the error was resolved:

          $('<style>')
            .attr("type", "text/css")
            .html('body.toolbar .atlwdg-TOP { top: ' + <strong>Drupal.toolbar.height() + 'px; }')</strong>
            .appendTo('head');
mdeltito’s picture

Status: Active » Needs review
FileSize
843 bytes

Attached patch checks if the Toolbar is enabled before attempting to apply styles to the collector widget.

LittleRedHen’s picture

The patch at #4 works for me. Thanks!

  • kasperg committed be262fc on 7.x-1.x authored by mdeltito
    Issue #2653580 by mdeltito: JS error - Cannot read property 'height' of...
kasperg’s picture

Status: Needs review » Fixed

I have committed the patch in #4. Thanks a bunch.

Status: Fixed » Closed (fixed)

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