The resulting audio elements have identical id’s but the audio stops when navigating. Any idea why?
I will say that the page structure is different but it’s the same type of element with the same id and referencing an identical audio file. The only other difference i can see is that the first audio element is inside a turbo-frame, but the link to the second page has target="_top" on it. Would that be the issue? and if so is there a way to make it work but keep the link working the same way?
Hey, I just tested out this use case locally and I think I discovered the issue.
Both elements must have the same id and also the data-turbo-permanent attribute otherwise it will not work.
If you have on one page the id=“persisted-audio” and data-turbo-permanent but on the other page you only had the id and no data-turbo-permanent it will not persist.
I just tried that. I added data-turbo-permanent to the audio element on the second page. When i go to the first page, start playing the audio, and clikc the link to the second page, the audio player doesn’t show up? It’s not even in the DOM? If I then refresh the second page it shows up again.
No idea about that, try debugging and make sure the elements are actually the same and they both exist on the page and are not lazy loaded or anything like that
I tried the same use case with your same exact code but instead of dom_id, I used a static id of “audio” and a src of a tmp file. And it worked fine when navigating. Another thing is if you are using target: “_top” to break out of a frame it will not respect data-turbo-permanent elements because that uses the standard browser refresh. If you need to change this then change the link from using target: “_top” to data-turbo-frame=“_top”