#628132: fix Views preview.

From: Damien Tournoud <damien@tournoud.net>


---
 admin.inc |    6 ++----
 ajax.js   |    9 ++++++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git includes/admin.inc includes/admin.inc
index 81f45fc..a9919ed 100644
--- includes/admin.inc
+++ includes/admin.inc
@@ -465,7 +465,7 @@ function views_ui_preview($js, $view) {
     $output .= $preview . $info;
   }
 
-  if (!$js) {
+  if ($js !== 'ajax') {
     views_add_css('views-admin');
     drupal_set_title($view->get_title());
     return $output;
@@ -481,9 +481,7 @@ function views_ui_preview($js, $view) {
       $display = '<div class="views-messages">' . $messages . '</div>';
     }
     $display .= $output;
-    if ($display) {
-      $commands[] = views_ajax_command_set_form($display, $view->get_title());
-    }
+    $commands[] = ajax_command_replace('#views-live-preview', $display);
     ajax_render($commands);
   }
 }
diff --git js/ajax.js js/ajax.js
index c4f99e9..c24a221 100644
--- js/ajax.js
+++ js/ajax.js
@@ -62,7 +62,7 @@ Drupal.theme.tableDragChangedWarning = function () {
 Drupal.behaviors.viewsAjax = {
   attach: function(context) {
     // Bind AJAX behaviors to all items showing the class.
-    $('.views-ajax-link', context).once('views-ajax-processed').each(function () {
+    $('.views-ajax-link', context).once('views-ajax').each(function () {
       var element_settings = { 'event': 'click' };
 
       // For anchor tags, these will go to the target of the anchor rather
@@ -73,6 +73,13 @@ Drupal.behaviors.viewsAjax = {
       var base = $(this).attr('id');
       Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
     });
+
+    $('form#views-ui-preview-form', context).once('views-ajax').each(function () {
+      var element_settings = { 'url': $(this).attr('action'), 'event': 'submit', 'progress': { 'type': 'throbber' } };
+      var form = $(this)[0];
+      form.form = form;
+      Drupal.ajax[$(this).attr('id')] = new Drupal.ajax($(this).attr('id'), form, element_settings);
+    });
   }
 };
 
