-
-
Save jittarao/09e834d2e8f77046643d3785604cb3ec to your computer and use it in GitHub Desktop.
| <!-- Place this code in the <body> tag --> | |
| <!-- start Gist JS code--> | |
| <script> | |
| var hasGistScriptLoaded = false; | |
| (function(){ | |
| var loadEvent = 'turbolinks:load'; | |
| var unloadEvent = 'turbolinks:before-visit'; | |
| var loadHandler = function() { | |
| document.removeEventListener(loadEvent, loadHandler); | |
| document.addEventListener(unloadEvent, unloadHandler); | |
| setTimeout(function () { | |
| if(!hasGistScriptLoaded) { | |
| hasGistScriptLoaded = true; | |
| // Replace WORKSPACE_ID text with your Workspace ID | |
| gist.setAppId("WORKSPACE_ID"); | |
| gist.trackPageView(); | |
| } | |
| }, 500); | |
| }; | |
| var unloadHandler = function() { | |
| document.removeEventListener(unloadEvent, unloadHandler); | |
| delete (window.gist); | |
| hasGistScriptLoaded = false; | |
| }; | |
| document.addEventListener(loadEvent, loadHandler); | |
| setTimeout(function() { | |
| (function(d,h,w){var gist=w.gist=w.gist||[];gist.methods=['trackPageView','identify','track','setAppId'];gist.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);gist.push(e);return gist;}};for(var i=0;i<gist.methods.length;i++){var c=gist.methods[i];gist[c]=gist.factory(c)}s=d.createElement('script'),s.src="https://widget.getgist.com",s.async=!0,e=d.getElementsByTagName(h)[0],e.appendChild(s),s.addEventListener('load',function(e){},!1)})(document,'head',window); | |
| }, 1); | |
| })(); | |
| </script> |
@sadiqmmm I will test this and come back shortly. Meanwhile, see if commenting line number 8 helps resolve this.
@jittarao Thanks for the update. I have commented the line 8 "document.addEventListener(unloadEvent, unloadHandler);" Error is gone. But the widget is not loading up. Only full page refresh is working correctly. Not with the Turbolinks.
@sadiqmmm just to confirm, have you put the original code in the head tag or body tag? Ideally, it should go into the body tag.
@jittarao Working after moving the code from head tag to body tag. Thanks
@jittarao on rails 6 using turbo instead of turbolink, it could be nice to have the possibility to add in body an empty "#gist-app" div in data-turbo-permanent in order to keep the frame loaded throw navigation. Or defining a div parent ?
The main problem i have is that events on document are stacking on each load...
events come from :
_cfCommonFunctions.prototype.gtAddMultipleListenerToDoc(document, ["touchstart", "touchmove", "touchend", "mouseover", "mousemove", "mousedown", "mouseup", "click", "keydown", "keypress", "keyup", "submit", "change", "scroll", "resize", "dblclick"], _cfCommonFunctions.prototype.gtHandlerOfListener, !1),



@sadiqmmm Can you share which line in the code this error is coming from?