Score:0

Ajax only binding once

kr flag

It looks like Drupal changed to a different, non jQuery version of once, and now all of our code that updates the DOM and needs to reattach the events for AJAX elements no longer reattaches them; Drupal.attachBehaviors() no longer works.

id flag
This sounds like https://www.drupal.org/project/drupal/issues/3254840
Score:1
kr flag

I have to assume that the changes to core/once library in 9.2 described here - https://www.drupal.org/node/3158256 , then also being used in core Ajax, changed the behavior. Though since we have a more global "once" class, if I understand correctly, we gain the ability to add and remove "once".

So this is what ended up working, but I'm hesitant.

(function (Drupal, once) {
...

/* After js (vue in this case) renders & kills event binding */

once.remove('drupal-ajax', '[data-once=drupal-ajax]');
Drupal.attachBehaviors();

...
})(Drupal, once);
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.