Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I needed class who I can put on some link to exclude Ajax normal behaviors. Because my drupal webSite is entire ajax.
So i did that :
In ajax _pages.module :
In line 130
+++
$form['ajax_pages_links_excluder'] = array(
'#type' => 'textfield',
'#title' => t('Ajax links exclusion'),
'#default_value' => variable_get('ajax_pages_links_excluder', NULL),
'#size' => 60,
'#description' => t('A jQuery selector that specifies all of the links that you DONT want to enable Ajax page loads for.<br />Example: .ajaxOff'),
'#required' => FALSE,
); // /!\ Suround ".ajaxOff" with < code > balise
In line 73
+++
'linksExcluder' => variable_get('ajax_pages_links_excluder', NULL),
In ajax _pages.js :
In line 48
--- $(document).delegate(settings.ajaxPages.linksSelector, 'click', function(e) {
+++ $(document).delegate(settings.ajaxPages.linksSelector + ":not('" + settings.ajaxPages.linksExcluder + "')", 'click', function(e) {
Let me know if I'm doing it wrong. I have no illusions about it, I'm pretty sure it's the bad way to do it but it work and it a good new feature.
Comments
Comment #1
bumpshoveit CreditAttribution: bumpshoveit commentedComment #2
jamix CreditAttribution: jamix commentedIf the link you want to exclude has a particular CSS class (e.g.
ajax-pages-exclude
), you can simply update your Ajax links selector in the module options as follows:#page-wrapper a:not(.ajax-pages-exclude)
This will tell Ajax pages not to attach itself to the links of class
ajax-pages-exclude
.There's more on what you can do with the selectors in jQuery documentation.
Comment #3
T.Mardi CreditAttribution: T.Mardi commentedHi jamix, can this be used to exclude forms too? Coming from the related issue about disabling ajax on forms.
Comment #4
jamix CreditAttribution: jamix commentedNo, I'm afraid not. Excluding forms requires some kind of a different approach implemented.