Problem/Motivation
The module stops loading new content after X amount of items. I've got it setup to load 8 items per page, it loads upto 16 items and than it stops in the infinite scroll mode.
When using it in the 'load more button' mode, it loads all the new results, but appends a ?page=x to the url
i'm not sure when the problem started, so i'm not sure if the issue is because of drupal 9.3.x
Setup:
php8.0.x
drupal 9.3.0-RC1
Custom theme based on the Barrio main theme
Steps to reproduce
Create a view that holds items and set it to infinite scroll ( Automatically Load Content) with 8 items / pages and try to scroll past those items.
The issue can be tested at the following url:
https://metalfans.be/metaloptredens
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
mateb commentedI have experienced the same issue. After a bit investigation it seems to be Drupal 9 has a new AJAX View JS file: /core/modules/views/js/ajax_view.js which does not contain "something" which is needed for working of Views Infinite Scroll. I guess this is something with a class 'js-view-dom-id-' ~ dom_id. Infinite scroll loads next page content ONLY once (because of class is needed for AJAX) and after does not work anymore.
I know hacking core is a totally wrong way, but if you copy back (backup before) and overwrite /core/modules/views/js/ajax_view.js from Drupal 8 version, that could be a quickfix. That's my 2 cents. Hoping contrib module developers can solve it soon.
Comment #3
demon326 commentedI did some tests and it stops working after using the file provided by drupal 9.3. The only real difference between 9.3 and the other branch are as follow:
9.3
line 70 -71
Line 83:
9.2
line 70 - 71
Line 83:
Edit:
Afer some more searching i found that the issue is with the code on line 70:
replacing
once('ajax-pager', this.$view.filter($.proxy(this.filterNestedViews, this))).forEach($.proxy(this.attachPagerAjax, this));with:
makes the views load more working again like old times.
Comment #4
ozinWith this patch module will work only on Drupal core ^9.2.0.
Check this issue Remove jQuery dependency from the once feature.
I'm not sure what exactly causes the issue, but with these fixes, it works on core 9.3.0.
Comment #6
kevin.pfeifer commentedThis patch fixes the "Load more button breaks after X load more actions have been done" BUT
it breaks the automatic load more action which should be performed if the user scrolls to the end of the view.
Problem here is the fact, that $pager is undefined/empty at that moment. But I don't know why because the usage of the new
once()JS method seems fine to meComment #7
kevin.pfeifer commentedThe only thing I adjusted was the part where it
forEach()over the.once()part.It seems like
thisat this point is not the current looped item, therefore I just put theeleminto theforEach(elem)and created the jQuery object with thatvar $pager = $(elem);This fixed the problem for me (both auto-load more and load more after X actions)
EDIT: I created the patch file wrong, new one incoming shortly
Comment #8
kevin.pfeifer commentedHere is the new patch
Comment #9
kevin.pfeifer commentedComment #10
stevieb commentedkevin.pfeife's patch in #8 fixes the issue for me on multiple sites.
Comment #11
emek commentedI have tried the patch in #8 and it solves the problem with loading more using the button and the automatic loading of more.
Comment #12
neslee canil pintoOh, seems Drupal 9.3.x is causing this major issue.
Comment #13
neslee canil pintoBetter we create a new branch [2.0.x] that will support Drupal 9.2 and above and merge this commit there.
Comment #14
kevin.pfeifer commentedComment #15
michelrrr commentedI have the same issue, even with the patch applied on Drupal 9.3.0 with module 8.x-1.9.
Any patch available for 9.3.x ?
thanks
Comment #16
demon326 commentedMake sure your using the patch from #8 and clear all your caches. The patch does work on my site.
Comment #17
acbramley commentedPatch #8 fixed the issue for me. Agreed with #13 that this should be committed to a 2.x branch
Comment #18
omar alahmedThe patch in #8 does not work with Core 9.3.0. It worked when clicking the load more button for the first click, and in the second click the page reloads.
Comment #19
acbramley commented@Omar Alahmed worked for me on 9.3. The behaviour you are describing was what I was seeing before applying the patch.
Comment #20
andypostPlease exclude info file changes, it needs separate issue to add D10 support and stop declaring D8 support
Comment #21
hamze7qa commented@Omar Alahmed it's worked for me, make sure that you are using the latest version of the module then apply the patch.
Comment #22
gaurav_manerkar commentedI am facing same issue as #18 after updating code to 9.3.0
Comment #23
skeeve commented#8 works for me on 9.3.0
Comment #24
gaurav_manerkar commentedIts not working for me. On second click, page reloads with paramater ?page=2.
May be its related to https://www.drupal.org/project/drupal/issues/3254328
Comment #25
gaurav_manerkar commentedComment #26
marassa commented#8 fixed the problem for me with 9.3.0.
Comment #27
gaurav_manerkar commentedHi,
#8 works for me.
Comment #28
marassa commentedHi @gaurav.manerkar, yes it now works for me both with button and automatically. Something else must be wrong with your configuration. Are you sure the patch applied cleanly and completely over the latest module version? Did you clear the cache? I guess the developers will need more details on your config if it still doesn't work for you.
Comment #29
gaurav_manerkar commentedHi,
It is working for me after updating chrome.
Comment #30
chrbak commentedThe #8 patch is not working for me too, i am using the 8.x-1.9 version of the module and Drupal Version 9.3.2.
I have cleared the cache but the problem still occurs.
Comment #31
lobodakyrylo commented@chrbak, it seems the problem isn't in the patch. Try to to switch the Baltik theme and try again maybe the problem is in theme. The patch #8 works for me. I use 8.x-1.9 and Drupal 9.3.2.
Comment #32
marassa commented@chrbak, make sure to clear both your Drupal and browser caches, as it's javascript that can be cached by the browser.
Comment #33
sumeet-biswal commentedFor me also same issue as like @chrbak #30. (Drupal - 9.3.2. module 8.x-1.9). this #8 patch did not work for me after clearing drupal & browser cache several times.
it got work for me only when I followed below steps.
1- installed module version dev-8.x-1.x
2- then applied patches #8
3- cleared cache
it works now perfectly.
Comment #34
jurgenhaasRan into the same problem and patch from #8 saves the problem together with the dev release of this module. Thanks everyone working on this.
Comment #35
mathiasgmeiner commented#8 works for me, even with 8.x-1.9
Comment #36
kvantstudio commented#8 works for me for Drupal 9.3
Comment #37
jayhuskins#8 works for me on Drupal 9.3 as well.
Comment #39
neslee canil pintoCreated new branch 2.0.x for drupal ^9.2, will create a new release for this.
Comment #40
neslee canil pintoNew release has been created with this change - https://www.drupal.org/project/views_infinite_scroll/releases/2.0.0
Comment #41
neslee canil pintoComment #42
chrbak commentedI contacted with the theme builder and he wrote me back that he was overriding the 'infinite-scroll.js' file inside his theme. I applied the patch there too and all works fine.
Thank you for your help.
Comment #43
jupedega commentedI have installed version 2.0.0 on Drupal 9.3.3 and it keeps giving me the error.
I attach the error.
Thanks
Comment #44
marassa commented@jupedega Have you cleared BOTH drupal AND browser caches?
Comment #45
jupedega commentedYes we have cleared all caches and tested from an incognito tab. But it keeps failing.
Comment #46
kevin.pfeifer commented@jupedega: Can you confirm you have version 2.0 installed via
composer info drupal/views_infinite_scrollIf it still fails can you maybe check the JS Console in your browser after the first load more is successfull.
Maybe you have some JS error which prevents further JS code to execute.
Comment #47
marassa commented@jupedega Also please try with another theme and make sure your theme does not use its own copy of infinite-scroll.js like in #42.
Comment #48
jupedega commentedFirst of all, thank you very much for your comments.
I have done several tests, but when I changed the theme I saw that it already worked correctly.
I just saw that inside the theme in the js/override folder there is a file infinite-scroll.js.
So the problem is in the file that is overwriting the normal operation of the module.
Thank you very much for the answers.
Comment #49
kumkum29 commentedHi,
the last version (2.0) work very well on Drupal 9.3.
But, I get another problem with the pager. When I enable the Drupal cache (JS/CSS), the ajax behavior is broken, so the page is re-loaded.
In the views settings, i have disabled the cache option.
How to resolve this ? Thanks for your help.
Comment #50
marassa commented@kumkum29 if you get another problem please open another issue. And explain there what you mean by "the Drupal cache (JS/CSS)".
Comment #51
lowfidelityCan confirm version ^2.0 working flawlessly on D9.3 for me.
Comment #52
shriaasI updated to the latest version
2.0.0, but still facing the same issue onDrupal 9.2.9. Its not related to my custom theme, I checked on Bartik and Claro too they both have the same issue. Is there a separate ticket for9.2.9?Comment #54
4kant commentedHad the same issue here.
Patched 8.x-1.9 with #8, cleared drupal cache and had to clear browser´s cache for me to see that everything works fine now.
Thanks!
Comment #55
camslice commentedThis is still broken for me. I can click "Load more" the first time and it successfully updates the view items using Ajax. However the second time the Ajax fails and the page reloads. There are no errors in my Javascript console and I have no other copies/override of
infinite-scroll.jsin my theme.Drupal
v9.3.7views_infinite_scroll
v2.0Comment #56
camslice commentedApologies, I can confirm that views_infinite_scroll v2.0 does actually work with Drupal 9.3
However you need to clear ALL OF THE CACHES:
Comment #57
jukka792 commentedHi,
I am not able to get 2.0 working with D9.3.x
I am getting this JS error in web developr console and the infinite scrolling is not loading more content when scrolling. 1.9 version worked:
EDIT: clearing browser cache fixed it
Comment #58
amneh.shawish commentedPatch #8 works for me, but you need to clear the browser cache after apply it.
Comment #59
java008 commentedI am getting the following error,
An error occurred during the execution of the Ajax response: TypeError: $wrapper[method] is not a function
Comment #60
masoom2206 commented#8 works for me for 8.x-1.8 version
Comment #61
kevin.pfeifer commentedThis patch has only been released in 2.0 so you will have to update to that version to automatically get the fix.
https://www.drupal.org/project/views_infinite_scroll/releases/2.0.0
Otherwise you will have to add the patch manually to your composer.json
Comment #62
jwilson3Seeing this issue after 2nd load more.
Using Drupal 9.4, Acquia Site Studio 6.9, Views Infinite Scroll 2.0.0
Comment #63
aswathyajish commentedI have issue in my views page where this module is used. My drupal version is 9.4.5. When clicking on the "Load More" button at first time, the items are listed without any issues. When we click at second time, page refreshes and the "Reset" button appears twice.
I applied the patch in #8 and it saved my day. Thanks for the patch.
Comment #64
andikanio commentedThe bug still occured on Drupal 9.5.2 with v2.0.1,
But after downgrading to v1.9 and apply #8, the problem solved.
Comment #65
benito25 commentedBug resolved with 2.0.1 and D9.5.8.
Comment #66
iamfredrik commentedJust updated to 2.0.1 and D9.5.8. Alas, the bug is still there.
Comment #67
iamfredrik commentedI seem to have spoken too soon. For some reason it didn't work on my local development site, but it does work on the production site now.
Comment #68
nicolas s. commentedBug resolved with 2.0.1 and D9.5.9