4 votes
Accepted

Why isn't Drupal's core once() function working in my simple test script?

core/once isn't for doing something just once, but for attaching a script just once. Then it's up to your script's logic to actually do something just once. You could for example toggle a simple CSS ...
leymannx's user avatar
  • 18.1k
4 votes

Why does this JavaScript once implementation not work?

The new once() function from the new v10 core/once library always returns an array of elements (even if the selector matches only a single element). And vanilla JS arrays don't have a .on() function. ...
Hudri's user avatar
  • 5,500
3 votes

Why does this JavaScript once implementation not work?

jQuery Once was deprecated in Drupal 9 and removed from Drupal 10. The change record includes a conversion guide.
cilefen's user avatar
  • 5,967
2 votes
Accepted

Why does this JavaScript once implementation not work?

Below code is working for me if (once('addedtocart', '#addtocart', context).length) { $('#addtocart').on('click', function () { var product_id = document.getElementById("addtocart")....
Z CHAMP's user avatar
  • 62
2 votes
Accepted

A Drupal.behaviors stops working when I update the module

Jquery.once doesnt exist in d10 Use core/once
arnemichiels's user avatar
1 vote
Accepted

How to hide CKEditor5 toolbar plugin based on user permissions?

The simplest way to solve the problem would be to add one text format with the button, and one without, and assign those formats to roles with the appropriate permissions. It means two text formats to ...
Clive's user avatar
  • 167k

Only top scored, non community-wiki answers of a minimum length are eligible