Created
November 19, 2021 06:42
-
-
Save levmyshkin/a4a6714c19b32e3cec8143d76cad507f to your computer and use it in GitHub Desktop.
Drupal javascript behavior execute code once for element
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, once) { | |
Drupal.behaviors.myModuleBehavior = { | |
attach: function (context, settings) { | |
once('myCustomBehavior', 'input.myCustomBehavior', context).forEach(function () { | |
// Apply the myCustomBehaviour effect to the elements only once. | |
}); | |
} | |
}; | |
})(jQuery, Drupal, once); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment