Turbolinks compatibility


#1

I’m trying to integrate plotly.js in my rails 5 project.
I’m at a point that it works really well for the first page load, but it doesn’t work for other visits except in the case of a full reload. It seems the UI goes under the graph instead of over it.

Is there something I need to do or is plotly js not compatible with Turbolinks 5.1

Here’s the code.

document.addEventListener("turbolinks:before-cache", ->

#purge plot so it doesn’t go in cache
if ($("#graph-tester").length == 1)
Plotly.purge(‘graph-tester’)
)

document.addEventListener(“turbolinks:load”, ->
if ($("#graph-tester").length == 1)
#TESTER = document.getElementById(‘graph-tester’)
plotTest = Plotly.newPlot( ‘graph-tester’, plotlyData, plotlyLayout, {
scrollZoom: false,
displaylogo: false,
showLink: true
#displayModeBar: false
} )

Thank you