I’ve been trying to link behaviors between controllers.
Let’s say I have a list of div.block, each linked to a
blocks stimulus controller.
When I update one of this block, i’m replacing the HTML with
this.element.outerHTML which by definition disconnect this element, and creates a new one.
When I do update a block, I want to warn another controller (which wrappes almost the whole page) an update happened. For that, I added
data-action='update->othercontroller#update' and I wanted to dispatch an event (
update) like this:
)); when this new element
But for some reasons, the event is not dispatched.
When I load the page for the first time, the event is dispatched as the blocks gets connected to the controller.
But, when I update one block (replacing a block by another one), connect is triggered, but not the event dispatch line inside…
There is something I can’t see here.
If anyone has any idea where to look.
thx a lot