Hello 👋 How can we help?

Turbolinks

Only for those who are using Turbolinks on their websites
Written by Artem
Updated 1 month ago

Turbolinks feature works by intercepting all link clicks that would navigate to a page within the app, and instead makes the request via AJAX, replacing the body with the received content. This will prevent chat widget appearance while switching between pages, therefore you’ll need to re-initialize it again using this reinitHelpcrunchWidget method.

<script type="text/javascript">
  (function(w,d){
  w.HelpCrunch=function(){w.HelpCrunch.q.push(arguments)};w.HelpCrunch.q=[];
  function r(){var s=document.createElement('script');s.id='helpcrunch-widget-script';s.async=1;s.type='text/javascript';s.src='https://widget.helpcrunch.com/';(d.body||d.head).appendChild(s);}
  w.helpcrunchInitWidget = r;
  if(w.attachEvent){w.attachEvent('onload',r)}else{w.addEventListener('load',r,false)}
  })(window, document);

  function runHelpCrunchMethods() {
    HelpCrunch('init', 'YOUR_ORGANIZATION_NAME', {
    applicationId: YOUR_APPLICATION_ID,
    applicationSecret: 'YOUR_APPLICATION_SECRET'});
    HelpCrunch('showChatWidget');
  }

  runHelpCrunchMethods();

  function reinitHelpcrunchWidget() {
    var helpcrunchWidgetScript = document.getElementById("helpcrunch-widget-script");
    var helpcrunchIframeWrapper = document.querySelector('.helpcrunch-iframe-wrapper');

    if (helpcrunchWidgetScript && !helpcrunchIframeWrapper) {
      helpcrunchWidgetScript.parentNode.removeChild(helpcrunchWidgetScript);
    }

    if (!helpcrunchIframeWrapper) {
      helpcrunchInitWidget();
      setTimeout(function() {
        runHelpCrunchMethods();
      }, 500);
    }
  }
</script>
Did this answer your question?