22/02/2025, by Anonymous (not verified) Forums Theming Drupal behaviors (Drupal.behaviors) are still part of javascript in core. These behaviors will be executed on every request, including AJAX requests. Don't forget to add a dependency to core/drupal in order to use Behaviors. Below is an example of a Drupal Javascript Behavior. (function ($) { 'use strict'; Drupal.behaviors.awesome = { attach: function(context, settings) { $('main', context).once('awesome').append('<p>Hello world</p>'); } }; }(jQuery)); Log in to post comments Log in to post comments
Drupal behaviors (Drupal.behaviors) are still part of javascript in core. These behaviors will be executed on every request, including AJAX requests. Don't forget to add a dependency to core/drupal in order to use Behaviors. Below is an example of a Drupal Javascript Behavior. (function ($) { 'use strict'; Drupal.behaviors.awesome = { attach: function(context, settings) { $('main', context).once('awesome').append('<p>Hello world</p>'); } }; }(jQuery)); Log in to post comments
Drupal behaviors (
Drupal.behaviors) are still part of javascript in core. These behaviors will be executed on every request, including AJAX requests.Below is an example of a Drupal Javascript Behavior.