Skip to content
Snippets Groups Projects

Issue #3374575: Replace jquery.once by core/once

3 files
+ 26
19
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -7,26 +7,27 @@
* Drupal behaviors:
*
* Means the JS is loaded when page is first loaded
* + during AJAX requests (for newly added content)
* use jQuery's "once" to avoid processing the same element multiple times
* http: *api.jquery.com/one/
* \+ during AJAX requests (for newly added content)
* use "once" to avoid processing the same element multiple times
* use the "context" param to limit scope, by default this will return document
* use the "settings" param to get stuff set via the theme hooks and such.
*
*
* Avoid multiple triggers by using jQuery Once
* Avoid multiple triggers by using Once
*
* EXAMPLE 1:
*
* $('.some-link', context).once('js-once-my-behavior').click(function () {
* // Code here will only be applied once
* once('js-once-my-behavior', '.some-link', context).forEach(function(element) {
* $(element).click(function () {
* // Code here will only be applied once
* });
* });
*
* EXAMPLE 2:
*
* $('.some-element', context).once('js-once-my-behavior').each(function () {
* once('js-once-my-behavior', '.some-element', context).forEach(function (element) {
* // The following click-binding will only be applied once
* * });
* });
*/
(function ($, Drupal, window, document) {
@@ -73,10 +74,10 @@
var items = list.children('li');
items.once('js-once-p-dialog-list').each(function() {
once('js-once-p-dialog-list').forEach(function(itemElement) {
// hover or touch on the info-icon, toggles up the description and closes all others that are open
var item = $(this),
var item = $(itemElement),
trigger = item.find('.paragraphs-add-dialog-row__description__icon'),
tooltip = item.find('.paragraphs-add-dialog-row__description__content');
Loading