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

demon326 created an issue. See original summary.

mateb’s picture

I 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.

demon326’s picture

I 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

once('exposed-form', this.$exposed_form).forEach($.proxy(this.attachExposedFormAjax, this));	
once('ajax-pager', this.$view.filter($.proxy(this.filterNestedViews, this))).forEach($.proxy(this.attachPagerAjax, this));	

Line 83:

 $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form).not('[data-drupal-selector=edit-reset]').each(function (index) {	

9.2
line 70 - 71

    this.$exposed_form.once('exposed-form').each($.proxy(this.attachExposedFormAjax, this));
    this.$view.filter($.proxy(this.filterNestedViews, this)).once('ajax-pager').each($.proxy(this.attachPagerAjax, this));

Line 83:

    $('input[type=submit], input[type=image]', this.$exposed_form).not('[data-drupal-selector=edit-reset]').each(function (index) {

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:

 this.$view.filter($.proxy(this.filterNestedViews, this)).once('ajax-pager').each($.proxy(this.attachPagerAjax, this));

makes the views load more working again like old times.

ozin’s picture

Title: Stops loading after X amount of items » Stops loading after X amount of items(Drupal ^9.2.0 )
Version: 8.x-1.9 » 8.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new2.49 KB

With 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.

Status: Needs review » Needs work

The last submitted patch, 4: views_infinite_scroll-3252577-9.2.x_support_1.patch, failed testing. View results

kevin.pfeifer’s picture

This 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 me

kevin.pfeifer’s picture

The only thing I adjusted was the part where it forEach() over the .once() part.

It seems like this at this point is not the current looped item, therefore I just put the elem into the forEach(elem) and created the jQuery object with that var $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

kevin.pfeifer’s picture

StatusFileSize
new2.62 KB

Here is the new patch

kevin.pfeifer’s picture

Status: Needs work » Needs review
stevieb’s picture

kevin.pfeife's patch in #8 fixes the issue for me on multiple sites.

emek’s picture

I have tried the patch in #8 and it solves the problem with loading more using the button and the automatic loading of more.

neslee canil pinto’s picture

Oh, seems Drupal 9.3.x is causing this major issue.

neslee canil pinto’s picture

Better we create a new branch [2.0.x] that will support Drupal 9.2 and above and merge this commit there.

kevin.pfeifer’s picture

Status: Needs review » Reviewed & tested by the community
michelrrr’s picture

I 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

demon326’s picture

Make sure your using the patch from #8 and clear all your caches. The patch does work on my site.

acbramley’s picture

Issue summary: View changes

Patch #8 fixed the issue for me. Agreed with #13 that this should be committed to a 2.x branch

omar alahmed’s picture

The 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.

acbramley’s picture

@Omar Alahmed worked for me on 9.3. The behaviour you are describing was what I was seeing before applying the patch.

andypost’s picture

Please exclude info file changes, it needs separate issue to add D10 support and stop declaring D8 support

hamze7qa’s picture

@Omar Alahmed it's worked for me, make sure that you are using the latest version of the module then apply the patch.

gaurav_manerkar’s picture

I am facing same issue as #18 after updating code to 9.3.0

skeeve’s picture

#8 works for me on 9.3.0

gaurav_manerkar’s picture

Its 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

gaurav_manerkar’s picture

Status: Reviewed & tested by the community » Needs work
marassa’s picture

Status: Needs work » Reviewed & tested by the community

#8 fixed the problem for me with 9.3.0.

gaurav_manerkar’s picture

Hi,

#8 works for me.

marassa’s picture

Hi @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.

gaurav_manerkar’s picture

Hi,

It is working for me after updating chrome.

chrbak’s picture

The #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.

lobodakyrylo’s picture

@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.

marassa’s picture

@chrbak, make sure to clear both your Drupal and browser caches, as it's javascript that can be cached by the browser.

sumeet-biswal’s picture

For 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.

jurgenhaas’s picture

Ran into the same problem and patch from #8 saves the problem together with the dev release of this module. Thanks everyone working on this.

mathiasgmeiner’s picture

#8 works for me, even with 8.x-1.9

kvantstudio’s picture

#8 works for me for Drupal 9.3

jayhuskins’s picture

#8 works for me on Drupal 9.3 as well.

neslee canil pinto’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Created new branch 2.0.x for drupal ^9.2, will create a new release for this.

neslee canil pinto’s picture

New release has been created with this change - https://www.drupal.org/project/views_infinite_scroll/releases/2.0.0

neslee canil pinto’s picture

Assigned: demon326 » Unassigned
Status: Reviewed & tested by the community » Fixed
chrbak’s picture

I 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.

jupedega’s picture

StatusFileSize
new20.47 MB

I have installed version 2.0.0 on Drupal 9.3.3 and it keeps giving me the error.

I attach the error.

Thanks

marassa’s picture

@jupedega Have you cleared BOTH drupal AND browser caches?

jupedega’s picture

Yes we have cleared all caches and tested from an incognito tab. But it keeps failing.

kevin.pfeifer’s picture

@jupedega: Can you confirm you have version 2.0 installed via composer info drupal/views_infinite_scroll
If 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.

marassa’s picture

@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.

jupedega’s picture

First 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.

kumkum29’s picture

Hi,

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.

marassa’s picture

@kumkum29 if you get another problem please open another issue. And explain there what you mean by "the Drupal cache (JS/CSS)".

lowfidelity’s picture

Can confirm version ^2.0 working flawlessly on D9.3 for me.

shriaas’s picture

I updated to the latest version 2.0.0, but still facing the same issue on Drupal 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 for 9.2.9?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

4kant’s picture

Had 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!

camslice’s picture

This 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.js in my theme.

Drupal v9.3.7
views_infinite_scroll v2.0

camslice’s picture

Apologies, 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:

  • Browser
  • Application
  • Varnish
jukka792’s picture

Hi,

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:

VM547:47 
        
       Uncaught TypeError: Cannot read properties of undefined (reading 'remove')
    at S.fn.init.$.fn.infiniteScrollInsertView (<anonymous>:47:17)
    at Drupal.AjaxCommands.insert (ajax.js?v=9.3.9:550:23)
    at ajax.js?v=9.3.9:446:44
    at Array.forEach (<anonymous>)
    at Drupal.Ajax.success (ajax.js?v=9.3.9:444:33)
    at Object.success (ajax.js?v=9.3.9:241:21)
    at c (jquery.min.js?v=3.6.0:2:28327)
    at Object.fireWith [as resolveWith] (jquery.min.js?v=3.6.0:2:29072)
    at l (jquery.min.js?v=3.6.0:2:79901)
    at XMLHttpRequest.<anonymous> (jquery.min.js?v=3.6.0:2:82355)

EDIT: clearing browser cache fixed it

amneh.shawish’s picture

Patch #8 works for me, but you need to clear the browser cache after apply it.

java008’s picture

I am getting the following error,
An error occurred during the execution of the Ajax response: TypeError: $wrapper[method] is not a function

masoom2206’s picture

#8 works for me for 8.x-1.8 version

kevin.pfeifer’s picture

This 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

jwilson3’s picture

Seeing this issue after 2nd load more.

Using Drupal 9.4, Acquia Site Studio 6.9, Views Infinite Scroll 2.0.0

aswathyajish’s picture

I 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.

andikanio’s picture

The bug still occured on Drupal 9.5.2 with v2.0.1,
But after downgrading to v1.9 and apply #8, the problem solved.

benito25’s picture

Bug resolved with 2.0.1 and D9.5.8.

iamfredrik’s picture

Just updated to 2.0.1 and D9.5.8. Alas, the bug is still there.

iamfredrik’s picture

I 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.

nicolas s.’s picture

Bug resolved with 2.0.1 and D9.5.9