Events on turbo frames?

Hi,

I would like to have events on a turbo frame to know when the navigation changes.

I have a get form, Each time I submit this form I want the URL to change but also the viewport to not reset scroll.

If my frame has a target _top, my URL changes but the viewport scroll resets.

So I thought having events on the frame would allow me to use the history API to perform what I want, and I guess it should pretty useful overall.

I tried without success with the events present in the handbook, any way to accomplish that ?

I was looking for the same and I think this Event to know a `turbo-stream` has been rendered answers why there is no event for that. (Use MutationObservers)

Indeed ! We can use it to catch the update of the src attribute of the frame, brilliant ! Thanks !

FWIW here’s what I ended up doing : https://gist.github.com/Intrepidd/ac68cb7dfd17d422374807efb6bf2f42

1 Like