summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2008-09-22 20:06:47 (GMT)
committer Earl Miles2008-09-22 20:06:47 (GMT)
commit14997ac5efafd7a8681a7fbe83aee4fb73250bc9 (patch)
tree32aceb70941963392bbaa87203878026f2c9f5ec
parent86433f630c4f5af323f6fb0ec664737974e2a197 (diff)
#311745 by mooffie: Incorrect use of replaceWith caused invalid data sent through attachBehaviors().
-rw-r--r--js/ajax_view.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/js/ajax_view.js b/js/ajax_view.js
index 12f5d94..329cce8 100644
--- a/js/ajax_view.js
+++ b/js/ajax_view.js
@@ -20,10 +20,19 @@ Drupal.Views.Ajax.ajaxViewResponse = function(target, response) {
alert(response.debug);
}
+ var $view = $(target);
+
// Check the 'display' for data.
if (response.status && response.display) {
- var view = $(target).replaceWith(response.display).get(0);
- Drupal.attachBehaviors(view);
+ var $newView = $(response.display);
+ $view.replaceWith($newView);
+ $view = $newView;
+ Drupal.attachBehaviors($view.parent());
+ }
+
+ if (response.messages) {
+ // Show any messages (but first remove old ones, if there are any).
+ $view.find('.views-messages').remove().end().prepend(response.messages);
}
};
@@ -143,4 +152,4 @@ Drupal.behaviors.ViewsAjaxView = function() {
});
});
}
-}; \ No newline at end of file
+};