New answers tagged javascript
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")....
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.
...
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.
2
votes
A Drupal.behaviors stops working when I update the module
Jquery.once doesnt exist in d10
Use core/once
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();
...
Top 50 recent answers are included
Related Tags
javascript × 31997 × 995
theming × 428
views × 405
ajax × 389
8 × 342
forms × 282
media × 124
nodes × 119
entities × 108
6 × 104
blocks × 74
webforms × 67
users × 61
navigation × 52
hooks × 51
files × 48
chaos-tool-suite × 45
datetime × 40
9 × 38
commerce × 36
google-maps × 35
location × 34
wysiwyg × 33
routes × 31