I am using Stimulus (via stimulus-rails 0.1.2) in a Rails (188.8.131.52) application.
I have an ajax call via fetch in a Stimulus controller (which works great). The results of the fetch add some elements to the dom. These elements contain
data-action attributes on the elements.
However, the action does not fire on the newly added DOM elements. Is there something that I need to do on the front end to get these new dom elements to be “hooked into” the Stimulus lifecycle?
Example of a dom element that is added:
<div data-controller="addresses"> <a data-action="click->addresses#copy" href="#">Copy</a> </div>
None of the
console.log statements above are executed.
I feel like I must be missing something very basic but I do not see any documentation nor none of the related topics seem to help me.