Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Latest commit

 

History

History
58 lines (46 loc) · 1.12 KB

File metadata and controls

58 lines (46 loc) · 1.12 KB
title contributors issues
Olark
user name
Empact
Ben Woosley
repo number
rails/turbolinks
166

Olark Chat Widget

olark.com

Overview

The supplied javascript will look something like this:

<script>
  window.olark || (function(c){
    // initialization code
  })({ 
    loader: "static.olark.com/jsclient/loader0.js", 
    name: "olark", 
    methods: ["configure", "extend", "declare", "identify"]
  });
  olark.identify('<your identity string>');
</script>

Solution

To get it working with Turbolinks:

  1. Move the script inside the head tags.
  2. Convert the anonymous initialization function into a named function.
  3. Bind this new function to the page:load event.

An example solution, in jQuery:

function initOlark(){
  c = {
    loader: "static.olark.com/jsclient/loader0.js", 
    name: "olark", 
    methods: ["configure", "extend", "declare", "identify"]
  };
  //initialization code
}

window.olark || initOlark();

$(document).bind('page:load', function(){
  initOlark();
  olark.identify('<your identity string>');
});