GithubHelp home page GithubHelp logo

Comments (7)

rafaltrojanowski avatar rafaltrojanowski commented on August 17, 2024 1
 $('[__jx__id], embed#__zopnetworkswf').remove()
 window.$zopim = undefined; 

Made trick! awesome.

from turbolinks-compatibility.

abhinavmsra avatar abhinavmsra commented on August 17, 2024 1

Its strange how setting window.$zopim to undefined solves the issue

from turbolinks-compatibility.

leonardostefani avatar leonardostefani commented on August 17, 2024

@andrewkouri I had with the same problem, when clicked in any link the zendesk stop of work, 'cause in my case i'm using zopim chat.

To fix my problem, I added 2 new lines. After/before of these lines:

window.zEmbed = window.zE = undefined
$('head iframe[src="javascript:false"]').remove()

I added:

$('[__jx__id], embed#__zopnetworkswf').remove()
window.$zopim = null

from turbolinks-compatibility.

MauricioMoraes avatar MauricioMoraes commented on August 17, 2024

@leonardostefani that did for me, thanks! But I've set window.$zopim = undefined;

Now my widget function looks like this:

// reference: http://reed.github.io/turbolinks-compatibility/zendesk_web_widget.html
function zendeskWebWidget(userName, userEmail, enableHelpCenter, enableChat){
  var zendesk_host = 'myhostname.zendesk.com';

  window.zEmbed = window.zE = undefined;
  $('head iframe[src="javascript:false"]').remove();
  // reference: https://github.com/reed/turbolinks-compatibility/issues/52
  $('[__jx__id], embed#__zopnetworkswf').remove()
  window.$zopim = undefined; 

  (function(url, host) {
    var queue = [],
        dom,
        doc,
        where,
        iframe = document.createElement('iframe'),
        iWin,
        iDoc;

    window.zEmbed = function() {
      queue.push(arguments);
    };

    window.zE = window.zE || window.zEmbed;
    window.zESettings = {
      webWidget: {
        helpCenter: {
          suppress: !enableHelpCenter
        },
        chat: {
          suppress: !enableChat
        }
      }
    };

    iframe.src = 'javascript:false';
    iframe.title = ''; iframe.role='presentation';  // a11y
    (iframe.frameElement || iframe).style.cssText = 'display: none';
    where = document.getElementsByTagName('script');
    where = where[where.length - 1];
    where.parentNode.insertBefore(iframe, where);

    iWin = iframe.contentWindow;
    iDoc = iWin.document;

    try {
      doc = iDoc;
    } catch(e) {
      dom = document.domain;
      iframe.src='javascript:var d=document.open();d.domain="'+dom+'";void(0);';
      doc = iDoc;
    }
    doc.open()._l = function() {
      var js = this.createElement('script');
      if (dom) this.domain = dom;
      js.id = 'js-iframe-async';
      js.src = url;
      this.t = +new Date();
      this.zendeskHost = zendesk_host;
      this.zEQueue = queue;
      this.body.appendChild(js);
    };
    doc.write('<body onload="document._l();">');
    doc.close();
  }('//assets.zendesk.com/embeddable_framework/main.js', "myhostname"));

  if(userName != ''){
    zE( function () {
      zE.identify({name: userName, email: userEmail});
    });
  }
}

And on the page header I have:

$(document).on("turbolinks:load", function() {
  var userName = 'username'; // fill it your way
  var userEmail = 'userEmail';
  var enableHelpCenter = false;
  var enableChat = true;

  zendeskWebWidget(userName, userEmail, enableHelpCenter, enableChat);
});

If anyone sees a better way to do this, please help me improve it! Thank you!

from turbolinks-compatibility.

zkingdesign avatar zkingdesign commented on August 17, 2024

@MauricioMoraes That worked perfectly. Thanks so much!

from turbolinks-compatibility.

Ghostavio avatar Ghostavio commented on August 17, 2024

hey, I was wondering if this still works @MauricioMoraes

from turbolinks-compatibility.

MauricioMoraes avatar MauricioMoraes commented on August 17, 2024

@Ghostavio we've ditched zendesk/zopim a year ago. So I have no idea if this workaround is still working. But my gut tells me that it should, because those widget inclusion scripts change very little over time (too much caching and compatibility problems to change it), and the main script is loaded from the server. So there is little risk of you wasting your time trying it out.

from turbolinks-compatibility.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.