Download & Extend

Ajax pager does not work as expected for nested views

Project:Views
Version:7.x-3.x-dev
Component:Miscellaneous
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Issue tags:Needs manual testing

Issue Summary

I have a view that loads other views. Both views, the parent and the nested ones, have Ajax enabled and have pagination. When a click to go to another page inside a nested view, the parent view is updated. This happens because the events are attached by the outermost parent/view, and not by the closest parent/view. The attached patch seems to fix this bug.

AttachmentSizeStatusTest resultOperations
views-ajax-pager-closest-parent.patch1.66 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).View details | Re-test

Comments

#1

So it seems to be already token into account that there is a problem with nested views, so i'm wondering why does the current code not work?

#2

The previous patch used jQuery.is() with an object which is not supported until jQuery 1.6. This patch uses object equality comparison, which is valid for DOM elements.

AttachmentSizeStatusTest resultOperations
1877446-3-views-ajax-pager-closest-parent.patch2.8 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1877446-3-views-ajax-pager-closest-parent_0.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#3

Status:needs review» needs work

The last submitted patch, 1877446-3-views-ajax-pager-closest-parent.patch, failed testing.

#4

The correct patch.

AttachmentSizeStatusTest resultOperations
1877446-3-views-ajax-pager-closest-parent.patch2.61 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).View details | Re-test

#5

I had similar issue with Ajax-loaded Views #1911582: Pager not working on Ajax-loaded Views.
Patch #4 fixed it. Thanks a lot.

#6

Status:needs work» needs review

Re-assigning to test.

#7

+++ b/js/ajax_view.jsundefined
@@ -94,6 +85,8 @@ Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
+  if (!$link.closest('.view').is(this.$view)) return;

+++ b/js/ajax_view.jsundefined
@@ -86,7 +86,7 @@ Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
+  if ($link.closest('.view')[0] != this.$view[0]) return;

Please use {}, as we don't use such code snippets in drupal.

#8

Please check the attached patch, now using {}.

AttachmentSizeStatusTest resultOperations
1877446-3-views-ajax-pager-closest-parent.patch3.49 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,603 pass(es).View details | Re-test

#9

Status:needs review» needs work

The last submitted patch, 1877446-3-views-ajax-pager-closest-parent.patch, failed testing.

#10

Status:needs work» needs review

#8: 1877446-3-views-ajax-pager-closest-parent.patch queued for re-testing.

#11

Status:needs review» needs work

Quick note that this patch completely broke AJAX on a views block with a summary pager attachment using AJAX.

#12

I'm glad that you found this while testing it! You saved a lot of sites just by posting this comment. Thank you!

#13

Thank you for posting this caiosba I was having this issue with the Load More pager. I had this working fine on a node that had an embedded View. But then (for reasons that I won't bother to explain!) I loaded this node in a nodequeue View and the pager just stopped working with Ajax. This patch got it working. Life saver! Thanks.
I was using Views version 7.x-3.6