jquery - Prevent from executing previous JavaScript with turbolinks and highcharts //LazyHighCharts -


i'm using turbolinks 5 , rails 5 version , newest highcharts. t

lazyhighcharts provides functionality turbolinks5 , wraps chart building javascript

(function() { document.addeventlistener("turbolinks:load", function() { //code window.chart_my = new highcharts.chart(options); }); })()

but when i'm navigating away page graph loaded turbolink, got error on newly loaded page.

uncaught error: highcharts error #13: www.highcharts.com/errors/13

looks previous javascript loaded "turbolinks:load" reevaluating , causing highchart throw error, because in new dom there's no element highchart graph renderedto.

i tried unbind "turbolinks:load" event document, doesn't work. reevaluates anyway.

thought solution fork lazyhighcharts, rewrite layout_helper, javascript outputed after dom element, slow page page flow be

loaded-dom (graph) evaluate js (sync) --> loaded-dom (graph) evaluate js (sync) ---> loaded-dom (graph) evaluate js (sync) etc. , slow down page load guess.

maybe guys here have solution problem.

made pull request lazy_high_charts

document.addeventlistener("turbolinks:load", function(e) {   // code   e.target.removeeventlistener(e.type, arguments.callee); }); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -