Issue with Ajax functionality and Drupal 11

Created on 1 January 2025, 3 months ago

Problem/Motivation

I've installed Views Load More on a newish Drupal 11 site (currently running 11.1.0), and for the life of me I can't get the Ajax functionality to work on this site with Views Load More. It works just fine when I uncheck the "Use AJAX" box under "Advanced >> Other" in the View configuration interface - but not when the box is checked.

Steps to reproduce

Here's my process:

  1. Create the Drupal 11 site, using the Minimal profile.
  2. Create a bunch of standard content
  3. Create a view of that standard content (in this case, just a list of titles linked to their content page)
  4. Install and enable the Views Load More module
  5. Update the pager on my view to use the "Load more pager"
  6. Update the pager options to use 2 items per page, and otherwise leave the rest of the "Pager options" interface alone. Apply those changes
  7. Save the view
  8. Load the view page that I've created, and click on the "Load more" link.
  9. Watch the little spinny interface spin, and each time I click it, get a console error of "An error occurred during the execution of the Ajax response: TypeError: $.trim is not a function"

Proposed resolution

I THINK the issue is that Drupal 11, which is using jQuery 4.0.0-beta.2, no longer supports the trim function - and that the code at /views_load_more/js/views_load_more.js uses the trim function on line 32. And that that element would need to be rewritten, to make this work with Drupal 11. But it's just a guess - there could be something else going on, too.

I should note that I found this out on my own custom Theme, so I checked to make sure this wasn't just a problem with my own Theme. But when I changed the site Theme to either Stark (11.1.0) or Claro (11.1.0) I still encountered this issue - which leads me to believe it's not an issue with my theme.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States paulkittredge

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024