better-ajaxify icon indicating copy to clipboard operation
better-ajaxify copied to clipboard

Possibility to update HTML partly

Open dtrunk90 opened this issue 3 years ago • 3 comments

If you want to have some elements untouched like <audio> elements (to preserve playing a radio stream for example) it should be possible to update HTML partly.

Currently it's hard to do this by using the ajaxify:render event and preventing the default because that event is using some variables like lastDomState and domStates which are used to update the browser history/address bar.

Maybe introducing a new event ajaxify:update which only updates body and title is a better approach. This way we can simply replace the default behaviour and update only the HTML parts we want.

dtrunk90 avatar Apr 05 '21 13:04 dtrunk90

@dtrunk90 is it an option to create audio in JavaScript, so this way DOM updates shouldn't break it.

chemerisuk avatar Jul 09 '21 19:07 chemerisuk

But wouldn't that require an audio element in the DOM? That would break it again.

dtrunk90 avatar Jul 09 '21 19:07 dtrunk90

@dtrunk90 you don't always need to add audio element to the DOM. Just call play() in a user action event handler.

I've made a simple demo https://jsbin.com/mumizojixo/1/edit?html,js,output

Try to play audio and then clear document body.

chemerisuk avatar Jul 09 '21 19:07 chemerisuk