How to integrate 3rd party javascript with turbo drive

61 Views Asked by At

I have a rails app using turbo. My live chat app breaks on any page navigation as the elements created for it are removed as the DOM refreshes. Is there a generally accepted solution to this?

1

There are 1 best solutions below

0
kyrylo On

You can make a DOM element permanent with data-turbo-permanent.

For example:

<div id="cart-counter" data-turbo-permanent>1 item</div>

The cart counter will persist between page loads.

Check more information here https://turbo.hotwired.dev/handbook/building#persisting-elements-across-page-loads