The dialog_loading command (Drupal.ajax.prototype.commands.dialog_loading) that is called to insert a loading throbber calls dialog_display (Drupal.ajax.prototype.commands.dialog_display). When calling the function, it passes in this as the ajax parameter.

/**
 * Command to open a loading dialog.
 */
Drupal.ajax.prototype.commands.dialog_loading = function(ajax, response, status) {
  Drupal.ajax.prototype.commands.dialog_display(this, {
    content: Drupal.theme('DialogThrobber'),
    title: Drupal.t('Loading...')
  });
};

In the context of the function call, this refers to Drupal.ajax.prototype.commands. In dialog_display, a settings variable is created and passed to Drupal.attachBehaviors.

// Apply any settings from the returned JSON if available.
var settings = response.settings || ajax.settings || Drupal.settings;
// Process any other behaviors on the content, and display the dialog box.
Drupal.attachBehaviors(new_content, settings);

response.settings is undefined, but ajax.settings is defined because ajax refers to Drupal.ajax.prototype.commands and Drupal.ajax.prototype.commands.settings is defined as a function in ajax.js.

/**
   * Command to set the settings that will be used for other commands in this response.
   */
  settings: function (ajax, response, status) {
    if (response.merge) {
      $.extend(true, Drupal.settings, response.settings);
    }
    else {
      ajax.settings = response.settings;
    }
  },

So when the attach functions of modules are called, the settings parameter they receive is a function, not an object, as shown here in the contributed extlink module:
https://skitch.com/jesse.beach/gpymr/developer-tools-http-provideotest.w...

Comments

jessebeach’s picture

StatusFileSize
new918 bytes

This is a bandaid on an issue that should probably be addressed more fundamentally. D7 now has a built-in throbber, so the dialog_loading function is no longer necessary.

I just replaced the reference to this with an empty literal object {}.

jessebeach’s picture

From a chat with effulgentsia

effulgentsia
4:42 why an empty object for first param? rather than the ajax object?

Jesse Beach
4:43 in this case, the ajax object is "undefined"
4:43 passing it straight through produces an error
4:43 the whole thing is wrong
4:43 the way the throbber is instantiated
4:43 but that's a big deal to fix
4:44 or a bigger deal than I have time for ATM

effulgentsia
4:45 can you add a code comment to that effect? like
4:45 // For some reason, the ajax parameter is undefined, so pass an empty object instead.
4:45 // @todo Refactor this to blah blah blah.

Jesse Beach
4:55 yes

jessebeach’s picture

StatusFileSize
new1.23 KB

Added comments explaining the patch to the patch.

jessebeach’s picture

Status: Active » Needs review

Setting to needs review.

ezman’s picture

Assigned: jessebeach » Unassigned

thanks for this patch - have encountered this problem today and changing "this" to "{}" works for me!

devin carlson’s picture

Status: Needs review » Closed (won't fix)

The 7.x-1.x branch of the Dialog module is unsupported.