Hi. I create a stimulus controller and use on a div element.
Now when change innerHTML of this div element with click on a button, text change but color not change to red and connect() not work.
<div data-controller="test">
<span>This text color change to red</span>
</div>
<button type="button" data-action="test#changeColor">click</button>
Hi. I create a stimulus controller and use on a div element.
Now when change innerHTML of this div element with click on a button, text change but color not change to red and connect() not work.
<div data-controller="test">
<span>This text color change to red</span>
<button type="button" data-action="test#changeColor">click</button>
</div>
The problem here is that connect does not re-run when you have changeColor called, that is only re-run when the controller connects.
You will need to re-write your controller to something like