AJAX is enabled in a View, pagination does not function as expected.

Created on 28 April 2025, 6 months ago

Problem/Motivation

When AJAX is enabled in a View, pagination does not function as expected. Instead of dynamically loading the next set of results via AJAX, the page reloads and remains on the current content without navigating to the next page. This issue disrupts the user experience, especially for sites relying on AJAX for seamless, dynamic interactions in Views, and makes it difficult to handle large datasets efficiently.

Steps to reproduce

Create or edit a View in Drupal that displays content, ensuring it includes pagination (e.g., set the pager to "Display a specified number of items per page").
Enable AJAX in the View settings by checking the "Use AJAX" option under the advanced settings.
Save the View and test it on the frontend.
Navigate to the View's page and attempt to use the pagination controls (e.g., click "Next" or a specific page number)

Proposed resolution

Modify the ViewAjaxController to ensure the page parameter is correctly processed during AJAX requests. Specifically:
Add logic to retrieve the current page parameter from the query string of the request URL.
Parse the URL and extract query parameters.
If the page parameter exists, explicitly set it in the request's query data.
This ensures that the pagination functionality works as intended with AJAX, allowing users to dynamically load paginated results without unnecessary page reloads.

🐛 Bug report
Status

Active

Version

10.4

Component

views.module

Created by

🇮🇳India ashetkar

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

Comments & Activities

Production build 0.71.5 2024