Skip to content

Instantly share code, notes, and snippets.

@levmyshkin
Last active November 19, 2021 13:16
Show Gist options
  • Save levmyshkin/d581a2cab9c7eef864c797b372a39467 to your computer and use it in GitHub Desktop.
Save levmyshkin/d581a2cab9c7eef864c797b372a39467 to your computer and use it in GitHub Desktop.
Drupal behavior run script once
(function (Drupal, drupalSettings, once) {
Drupal.behaviors.myBehavior = {
attach: function (context, settings) {
once('myBehavior', 'html', context).forEach( function () {
myFunction();
})
}
}
} (Drupal, drupalSettings, once));
foobar:
js:
js/foobar.js: {}
dependencies:
- core/drupal
- core/jquery
- core/once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment