Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
When there are multiple views blocks (embed or attachment) on a single page having Infinite scroll as pager settings. Clicking on single view pager leads to scroll other views as well.
Expected behavior: Clicking on individual view pager should lead to scroll only its own view not other views present on the page like normal pagination.
Comments
Comment #2
nghai CreditAttribution: nghai at ]init[ AG commentedComment #3
albertski CreditAttribution: albertski at Xeno Media, Inc. commentedI had a view inside each row of the main view and I was running into issues. To fix this I had to simply disable AJAX from the main view.
Comment #4
plato1123 CreditAttribution: plato1123 commentedI'm having a similar issue, we have a view that is a list and then we have another "attached" view that is a map up above it. When I enable ajax and click on load more additional items in our list load properly as they should but the map view at the top is also duplicated for each time load more is pressed. I've tried disabling ajax for one or the other and tried a variety of tweaks in the template file but cannot stop this behavior. I should point out this problem happens both with Views Infinite Scroll module or with Views build in ajax load more functionality, so it's not specifically an issue with Views infinite Scroll.
Comment #5
shubhangi1995we too had the same issue:
case:
main view - with infinte scroll
second view in the footer of main view - with infinite scroll
solution:
in our case the footer will never reach more than a specific number of nodes hence we removed the infinite scroll for footer view and kept showed the maximum nodes possible which in our case was 10.
Comment #6
Honza Pobořil CreditAttribution: Honza Pobořil as a volunteer commentedIs this bug also in 1.5 or it was introduced later?
If you will not reply in a ~week I will release 1.6 from the current dev.
Comment #7
shubhangi1995sorry for delay i could only reproduce it with 1.5
Comment #8
caitlinreid CreditAttribution: caitlinreid commentedI have created two views: a Page with better exposed filters, and an Attachment.
The filter and the pager (View Infinite Scroll) are inherited in the attachment.
When I click "show more" to expand the first view, items from both views are appended under each, instead of the view to which they belong.
Unfortunately, I get this error with Views Infinite Scroll versions 1.5 and 1.x-dev as well
Comment #9
marthinal CreditAttribution: marthinal at Bluespark commentedI have 2 views (2 blocks - same page) and the pager does not appear. I think the problem is that $pager_total has a global scope. See views_infinite_scroll_preprocess_views_infinite_scroll_pager()
We execute InfiniteScroll::updatePageInfo() twice. The second value overrides the first one. The result is that both pagers do not appear because the result is 0 for the second block.
Adding different pager ids does not fix the problem. I'm using Layout Builder.
Comment #10
YahyaAlHamadI get around this problem by using separate views.
Comment #11
YahyaAlHamadComment #12
Davy Duthoit CreditAttribution: Davy Duthoit at Smile commentedThanks to @marthinal comment #9 I have created a patch to work arround this issue.
This was tested on :
Comment #13
Jérôme DehorterHi,
Works for me on Drupal 8.7.5 and Views infinite scroll 8.x-1.6.
Thanks.
Comment #14
playful CreditAttribution: playful commentedWhen can we expect a release with this fixed?
Comment #15
yusufhmComment #16
playful CreditAttribution: playful commented#12 failed to apply on Drupal 8.8.4 with Views Infinite Scroll 8.x-1.7
Comment #17
Ralkeon CreditAttribution: Ralkeon commentedIs this committed to 1.7?
Comment #18
Honza Pobořil CreditAttribution: Honza Pobořil as a volunteer commentedCould more people confirm it does not break something else, please?
Comment #19
Honza Pobořil CreditAttribution: Honza Pobořil as a volunteer commentedComment #20
M@ster CreditAttribution: M@ster commentedpatch can't be applied for 1.7
But I found more simple solutions without patch: just use unique Pager ID
"If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible."
Comment #21
nsciaccaI was having a similar issue where the pager was not being rendered at all on an Attachment on a View block. Both using AJAX and sharing Exposed Filters. The fix was to apply this core patch, which exposed another option under the Pager region that enabled a "Render pager" option.
https://www.drupal.org/project/drupal/issues/2833734#comment-12790527
Comment #22
Neslee Canil PintoThis doesnt work for Drupal 8.8.4 with Views Infinite Scroll 8.x-1.7
Comment #23
debasisnaskar CreditAttribution: debasisnaskar as a volunteer and commentedHi,
I have tried using this patch and the infinite scroll works fine for me.
https://www.drupal.org/files/issues/drupal-allow-attachment-pager-283373...
If you are using composer. Then add the below chunk of code.
Comment #24
shubhangi1995Comment #25
SerShevchykI have checked the new version of the module. It looks like all functionality from patch #12 already in the module and we can close the issue.
Comment #26
shubhangi1995Comment #27
damian.skiba CreditAttribution: damian.skiba as a volunteer commentedThis patch is for 8.x-1.7 version. Based on #12.
Comment #28
tapasa CreditAttribution: tapasa commentedI have a view page with normal pagination wich I appended another view(a view block) with infinite scroll.
When i'm in the page and I click on the block infinite scroll "View more", both ajax pagers are triggered, so both response actions are executed.
But if I just click the normal pagination it works fine.
I tried every patch but none of them are working for this issue.
And reading the patches comments, I really don't see any relation with the issue title/description.
Edit: After doing some tests, I realized that the problem comes because view container 'js-view-dom-id-xxx' has another view container inside. Maybe is not infinite scroll's issue
Comment #29
fall_0ut CreditAttribution: fall_0ut at Openquest commentedThis patch is for 8.x-1.8 version. Based on #27.
Comment #30
sker101 CreditAttribution: sker101 as a volunteer commentedHaving a new problem now due to this commit in 1.8.
https://www.drupal.org/node/3034528
The Ajax subscriber is now using `$event->getRequest()->query->get('page')` to determine if `infinite_scroll` should be used and which would always be false if there are multiple views on the page.
According to the method `getUpdatedParameters`, the 'page' URL query parameter is a comma-delimited string. It could be something like `0,0,1` when there are multiple views on the page.
Comment #31
pankajsachdeva CreditAttribution: pankajsachdeva as a volunteer and commentedAny update on this issue. I am facing this issue.
I have tried #29 patch. But it doesn't resolve the issue.
Multiple scenarios to reproduce this issue are:
Scenario 1:
Create a page and block with Infinite Scroll. I have attached block view in page Footer attachment. When I am clicking on any of Load More button, both triggering and giving results at same time. I have checked in DOM, that Pager IDs are same for both of views.
Scenario 2:
To make Pager IDs different, I have created page view in different view and used Infinite Scroll with 0 Pager ID setting. And created second view which only contains Block with Infinite Scroll with Pager ID 50. Added this block view in Page Footer attachment. Getting weird behaviour. When clicking on first Load more, it loads random results.
Comment #32
asirjacques CreditAttribution: asirjacques as a volunteer and at Annertech commentedHey pankajsachdeva,
I was able to create the behavior you are looking for using views_load_more module instead. This module will let you add a jQuery selector. There is few tricks though.
For example with your scenario 1:
1 - Add the views_load_more pager to the page and the block.
2 - In the block view set the number of items you want to load.
3 - In the page view set the number of items to 0 (no limit) - This will make it bypass this condition:
VLMEventSubscriber.php line 37:
if ($pagerPlugin->getPluginId() == 'load_more' && $pagerPlugin->getCurrentPage() > 0) {
4 - Add a custom view template for your block and add an id to surround rows like this:
5 - Go back to your view, in the Page display go to Pager > Load more pager, 0 items > ADVANCED OPTIONS.
6 - Add
#my-id
into Content selector7 - You can add a custom pager template with nothing inside to remove the main view pager from the page display.
Also, note that only the page view must be ajax or you will have 2 ajax call.
Hope it helps!
Comment #33
lobodacyril CreditAttribution: lobodacyril as a volunteer commentedThe patch doesn't work when I use "Automatically Load Content" option because it unbinds all scroll events for window after the first page loading and binds new scroll event only for the current view and then only this view works. I suggest to unbind scroll event only for loading view. Here is my patch.
Notice that the new 2.0.x version was published so I changed this ticket to this branch. The patch should work for both versions but since D8 has EOL, it's prefered to use 2.0 version.
Comment #34
AnybodyThanks @lobodacyril - could this please be provided as MR?
Furthermore we need tests for the module to ensure this doesn't break again.