diff --git a/core/modules/views/js/ajax_view.js b/core/modules/views/js/ajax_view.js
index 85975b5..932c82f 100644
--- a/core/modules/views/js/ajax_view.js
+++ b/core/modules/views/js/ajax_view.js
@@ -18,12 +18,9 @@
   Drupal.behaviors.ViewsAjaxView = {};
   Drupal.behaviors.ViewsAjaxView.attach = function () {
     if (drupalSettings && drupalSettings.views && drupalSettings.views.ajaxViews) {
-      var ajaxViews = drupalSettings.views.ajaxViews;
-      for (var i in ajaxViews) {
-        if (ajaxViews.hasOwnProperty(i)) {
-          Drupal.views.instances[i] = new Drupal.views.ajaxView(ajaxViews[i]);
-        }
-      }
+      Drupal.views.sortByNestingLevel(drupalSettings.views.ajaxViews).forEach(function (item) {
+        Drupal.views.instances[item.key] = new Drupal.views.ajaxView(item.value);
+      });
     }
   };
 
@@ -38,6 +35,35 @@
   Drupal.views.instances = {};
 
   /**
+   * Helper function to sort views by nesting level.
+   *
+   * @param {object} ajaxViews
+   *   Object containing ajax view.
+   * @return {Array}
+   *   Array of views sorted by nesting level.
+   */
+  Drupal.views.sortByNestingLevel = function (ajaxViews) {
+    var ajaxViewsArray = [];
+
+    for (var i in ajaxViews) {
+      if (ajaxViews.hasOwnProperty(i)) {
+        ajaxViews[i].selector = '.js-view-dom-id-' + ajaxViews[i].view_dom_id;
+
+        ajaxViewsArray.push({
+          key: i,
+          value: ajaxViews[i],
+          nestingLevel: $(ajaxViews[i].selector).parents('.view').length
+        });
+      }
+    }
+
+    // Sort views by nesting level descending. The goal is to start with the innermost.
+    return ajaxViewsArray.sort(function (a, b) {
+      return b.nestingLevel - a.nestingLevel;
+    });
+  };
+
+  /**
    * Javascript object for a certain view.
    *
    * @constructor
@@ -48,8 +74,7 @@
    *   The DOM id of the view.
    */
   Drupal.views.ajaxView = function (settings) {
-    var selector = '.js-view-dom-id-' + settings.view_dom_id;
-    this.$view = $(selector);
+    this.$view = $(settings.selector);
 
     // Retrieve the path to use for views' ajax.
     var ajax_path = drupalSettings.views.ajax_path;
@@ -77,7 +102,7 @@
       submit: settings,
       setClick: true,
       event: 'click',
-      selector: selector,
+      selector: settings.selector,
       progress: {type: 'fullscreen'}
     };
 
@@ -88,11 +113,7 @@
     this.$exposed_form.once('exposed-form').each($.proxy(this.attachExposedFormAjax, this));
 
     // Add the ajax to pagers.
-    this.$view
-      // Don't attach to nested views. Doing so would attach multiple behaviors
-      // to a given element.
-      .filter($.proxy(this.filterNestedViews, this))
-      .once('ajax-pager').each($.proxy(this.attachPagerAjax, this));
+    this.$view.once('ajax-pager').each($.proxy(this.attachPagerAjax, this));
 
     // Add a trigger to update this view specifically. In order to trigger a
     // refresh use the following code.
@@ -126,20 +147,11 @@
   };
 
   /**
-   * @return {bool}
-   *   If there is at least one parent with a view class return false.
-   */
-  Drupal.views.ajaxView.prototype.filterNestedViews = function () {
-    // If there is at least one parent with a view class, this view
-    // is nested (e.g., an attachment). Bail.
-    return !this.$view.parents('.view').length;
-  };
-
-  /**
    * Attach the ajax behavior to each link.
    */
   Drupal.views.ajaxView.prototype.attachPagerAjax = function () {
     this.$view.find('ul.js-pager__items > li > a, th.views-field a, .attachment .views-summary a')
+      .once('attach-pager-ajax')
       .each($.proxy(this.attachPagerLinkAjax, this));
   };
 
