diff -u b/core/misc/ajax.js b/core/misc/ajax.js --- b/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -1114,15 +1114,12 @@ if ($new_content.parents('html').length > 0) { // Apply any settings from the returned JSON if available. settings = response.settings || ajax.settings || drupalSettings; - if (method === 'replaceWith') { - Drupal.attachBehaviors($wrapper.get(0), settings); - } - else { - // Attach behaviors to all element nodes. - $wrapper.children().each(function () { + // Attach behaviors to all element nodes. + $new_content.each(function () { + if (this.nodeType === Node.ELEMENT_NODE) { Drupal.attachBehaviors(this, settings); - }); - } + } + }); } },