Skip to content

Add guide for custom Stimulus controllers#1764

Open
falkgeist wants to merge 2 commits into
contao:mainfrom
falkgeist:falkgeist-stimulus-controllers-bundle
Open

Add guide for custom Stimulus controllers#1764
falkgeist wants to merge 2 commits into
contao:mainfrom
falkgeist:falkgeist-stimulus-controllers-bundle

Conversation

@falkgeist
Copy link
Copy Markdown
Contributor

No description provided.

@zoglo
Copy link
Copy Markdown
Member

zoglo commented May 21, 2026

Unsure if I like having this in the documentation since people don't really need to use stimulus but can use mutation observers. Especially not within the dev as it's not part of the Contao API.

@falkgeist
Copy link
Copy Markdown
Contributor Author

falkgeist commented May 21, 2026

I see your point.

The problem with mutation observers is, that any changes to the DOM based on the observers might in turn trigger Stimulus' observer 🤪. But that is a different issue, imho.

The issue described in the first paragraph is very real though, if you ask me:

Custom backend JS with listeners to the DOMContentLoaded event is only triggered on 'real' page loads, not Turbo navigation.

Implementing your own controller is not the definitive fix for that (there's your mentioned mutation observers or also Turbo events), but it does mitigate the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants