Skip to main content
drupalreleases
Release: Cms 2.2.3 — Update released for Drupal core (2.2.3)! Release: Easy Breadcrumb 2.0.11 — Minor update available for module easy_breadcrumb (2.0.11). Release: Bootstrap 8.x-3.42 — Minor update available for theme bootstrap (8.x-3.42). Release: Editoria11y Accessibility Checker 3.0.10 — Minor update available for module editoria11y (3.0.10). Release: Editoria11y Accessibility Checker 2.2.24 — Minor update available for module editoria11y (2.2.24). Release: Leaflet 10.4.13 — Minor update available for module leaflet (10.4.13). Release: Flag 5.1.1 — Minor update available for module flag (5.1.1). Release: Layout Paragraphs 3.0.0-beta5 — New beta version released for module layout_paragraphs (3.0.0-beta5). Module Revived: Bootstrap 8.x-3.41 — Theme bootstrap updated after 6 months of inactivity (8.x-3.41). Security Coverage: Component Library — Module component_library now has official Drupal security advisory coverage.

Ajax link

74 sites Security covered Drupal 8–11
View on drupal.org

The ajax_link module provides an easy way for developers to implement AJAX links that load and replace content in specific areas of a page. By adding simple data attributes to links, developers can control which content is loaded and how it's displayed, making it seamless for themers to integrate.

The ajax link module give tools for themers and developers to easily implements ajax links.

Core implements AjaxResponse methods, but if you already have a page with content you want to append or replace in an area, you have to define custom AjaxResponse to each cases.

This module implements a generic AjaxResponse which load and render page accessible by the link you click on, and only respond with the markup of the array to replace.

Nothing to configure from the UI, everything happens by data attributes on the links, so it's easy to access for themers.

The ajax_link/ajaxLink library needs to be attached on pages where you want to use ajax link.

Example :

I want to load the next page of the product list in the area matching the class products-list.
Define the link as an ajax link adding 'ajax-link' class to the link markup.
Add the 'data-ajax-link-selector' data attribute with css selector where to find and replace content : '.products-list'.
<a href="{{ url }}" class="ajax-link" data-ajax-link-selector=".products-list">This is an ajax link</a>

And in preprocess :

$variables['#attached']['library'][] = 'ajax_link/ajaxLink';

or twig :
{{ attach_library('ajax_link/ajaxLink') }}

Here is available settings for the link :

  • Class :
    • ajax-link : required, Let the module know this link is an ajax link
    • ajax-link-auto : optional, when the link will be 'visible' in the browser, the link will be automatically clicked. With this option, you can have an infinite scroll pager for example.
    • ajax-link-hidden : optional, hide the link. Compatible with ajax-link-auto
  • Data attributes :
    • data-ajax-link-selector: required, define the area to get content and to replace/append.
    • data-ajax-link-method: optional, Define the method to use : replace (default) OR append
    • data-ajax-link-history: optional, Set to 1 if you want the browser history to reflect the clicked link. Default to 0.
    • data-ajax-link-remove-after-execution: optional, remove link after execution. Default to true. Set value to false to keep
      the link displayed and executable.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

1 tracked project depends on this one

Activity

Tracked releases
6
Tracked since
Jul 2024
Latest release
3 months ago
Releases (12 mo)
2 ▼ from 3
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.6 Stable 8–11 Jun 20, 2026
1.0.5 Stable 8–11 Mar 26, 2026
1.0.4 Stable 8–11 Nov 19, 2024
1.0.3 Stable 8–11 Nov 18, 2024
1.0.2 Stable 8–11 Oct 9, 2024
1.0.1 Stable 8–11 Jul 24, 2024