New answers tagged

0 votes

Why does not this code 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
  • 32
3 votes

Why does not this code 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,244
2 votes

Why does not this code 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,270
2 votes

A Drupal.behaviors stops working when I update the module

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

Is there a reliable way to show Drupal messages from JavaScript?

This API available in Drupal since 8.7.0. See details here. Just an example: const messages = new Drupal.Message(); // Probably you want to clean up previously rendered messages: messages.clear(); ...
voleger's user avatar
  • 950

Top 50 recent answers are included