Javascript event not triggered

Hello,

I am trying to use Turbo with my PHP backend.

I tried using document.addEventListener('turbo:load' to initialize my wysiwyg editor on my “create” and “edit” page.

What I have is a webpage which displays my current item, lets say it is my blog post.
When I click on the “edit” link, some parts of the page gets replaced via turbo to edit this blogpost.
Unfortunately, the turbo:load event is not fired when a part of the website is replaced, it is only fired when the whole page gets replaced, hence my editor is not initialized correctly.

Is there another event which I might use?
Or am I doing somthing completely wrong?

Thanks and kind regards
Andreas

For turbo streams you would need to use turbo:before-stream-render.

see: Turbo Events

Note: There is a better approach if using stimulus.

Dynamic module import with Stimulus JS - DEV Community