In #3240131: Drupal.behavior gets attached multiple times instead of once, a check was added to prevent attaching multiple times. Unforunately, this also kills AJAX funktionallity, since AJAX will not pass in "document", but the respective element. Since we are loading the library on demand, this never gets executed since "document" never matches context.

Using context to pass in the detected elements to ClipboardJS seems the more suitable approach. Additionally, a "detach" function could be added to unregsiter possible clipboard events

CommentFileSizeAuthor
#2 3255469-1.patch924 bytesdrcolossos

Comments

DrColossos created an issue. See original summary.

drcolossos’s picture

StatusFileSize
new924 bytes
drcolossos’s picture

Status: Active » Needs review
drcolossos’s picture

Title: AJAX Request not working 2.0.1 » AJAX behavior not working 2.0.1
lind101’s picture

I am haing the same issue when trying to use the ClipboardJS field formatters for fields loaded inside a Modal. Unfortuantly, the patch in #2 doesn't seem to fix the problem for me.

sanduhrs’s picture

Version: 2.0.1 » 2.0.x-dev
Status: Needs review » Fixed

This obviously makes sense, thanks!

sanduhrs’s picture

Title: AJAX behavior not working 2.0.1 » Attach clipboardjs with native querySelectorAll on context

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.