Last active
November 19, 2021 13:16
-
-
Save levmyshkin/d581a2cab9c7eef864c797b372a39467 to your computer and use it in GitHub Desktop.
Drupal behavior run script once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (Drupal, drupalSettings, once) { | |
Drupal.behaviors.myBehavior = { | |
attach: function (context, settings) { | |
once('myBehavior', 'html', context).forEach( function () { | |
myFunction(); | |
}) | |
} | |
} | |
} (Drupal, drupalSettings, once)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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