ajax_dialog_filter
Automatically loads required AJAX dialog libraries when text formats contain links using the use-ajax class.
This is currently work in progress (WIP) - please help to get this tested and finished!
See https://www.drupal.org/docs/develop/drupal-apis/ajax-api/ajax-dialog-box... for examples.
Important: Only enable this for higher level text formats like "Full HTML" for user roles you can trust!
Enabling this text filter for untrusted roles can cause security risks.
Features
The Ajax Dialog Filter module ensures that any <a> tag inside a text‑formatted field that includes the use-ajax class automatically receives the required Drupal AJAX dialog libraries. This allows editors to create modal or off‑canvas AJAX dialogs directly from formatted text without writing custom code or attaching libraries manually.
What it does:
- Detects
class="use-ajax"class inside<a href="/node/123" class="use-ajax" data-dialog-type="modal">Open AJAX Modal</a>via text formats - Automatically attaches
core/drupal.ajax,core/drupal.dialog.ajax, and related libraries - Ensures AJAX dialogs work reliably even when triggered from CKEditor or other formatted text sources
Why use it:
- Ideal for sites that use modal dialogs for help text, embedded forms, or interactive UI elements
- Removes the need for custom preprocess hooks or theme overrides
- Ensures consistent behavior across all text formats and content types
Use cases:
- Opening modal forms from body text
- Triggering AJAX dialogs from CKEditor content
- Creating interactive help links or inline modal content
- Enabling editors to add AJAX dialogs without developer intervention
Post-Installation
After installing the module:
- Go to Configuration → Content authoring → Text formats and editors
- Edit the text format you want to support (e.g., Basic HTML)
- Enable AJAX dialog library loader in the filter list
- Place it near the bottom of the filter order
No additional configuration pages or content types are added. Once enabled, the filter automatically scans rendered text and attaches the required libraries whenever it finds a link with the use-ajax class.
Additional Requirements
This module has no additional requirements beyond Drupal core. It relies on the AJAX and dialog libraries already included in Drupal.