From 26bcdd01a1c1503893622b90635ef7261f87e6bb Mon Sep 17 00:00:00 2001
From: Mark Carver <mark.carver@me.com>
Date: Tue, 23 Apr 2013 18:57:42 -0500
Subject: Issue #1907472: Pager in views with ajax

---
 includes/theme.inc | 10 +++++++++-
 js/ajax_view.js    | 12 ++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 js/ajax_view.js

diff --git a/includes/theme.inc b/includes/theme.inc
index f5c511f..1bc2e8c 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -297,13 +297,21 @@ function bootstrap_js_alter(&$js) {
   if (module_exists('bootstrap_ui')) {
     libraries_load('bootstrap', 'minified');
   }
+
+  $theme_path = drupal_get_path('theme', 'bootstrap');

   // Replace core progress bar JS with the Bootstrap equivilent.
   if (isset($js['misc/progress.js']) && !empty($js['misc/progress.js'])) {
     unset($js['misc/progress.js']);
-    $progress = drupal_get_path('theme', 'bootstrap') . '/js/progress.js';
+    $progress = $theme_path . '/js/progress.js';
     $js[$progress] = drupal_js_defaults($progress);
   }
+
+  // Fix broken Views AJAX pagers.
+  if (module_exists('views') && !empty($js[drupal_get_path('module', 'views') . '/js/ajax_view.js'])) {
+    $ajax_view = $theme_path . '/js/ajax_view.js';
+    $js[$ajax_view] = drupal_js_defaults($ajax_view);
+  }

   $js = array_diff_key($js, $excludes);
   if (theme_get_setting('cdn_bootstrap')) {
diff --git a/js/ajax_view.js b/js/ajax_view.js
new file mode 100644
index 0000000..4154173
--- /dev/null
+++ b/js/ajax_view.js
@@ -0,0 +1,12 @@
+(function ($) {
+
+/**
+ * Override Views prototype function so it can recognize Bootstrap AJAX pagers.
+ * Attach the ajax behavior to each link.
+ */
+Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
+  this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a, .pagination ul li a')
+  .each(jQuery.proxy(this.attachPagerLinkAjax, this));
+};
+
+})(jQuery);
--
1.8.2

