Comments (7)
$('[__jx__id], embed#__zopnetworkswf').remove()
window.$zopim = undefined;
Made trick! awesome.
from turbolinks-compatibility.
Its strange how setting window.$zopim
to undefined
solves the issue
from turbolinks-compatibility.
@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.
@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.
@MauricioMoraes That worked perfectly. Thanks so much!
from turbolinks-compatibility.
hey, I was wondering if this still works @MauricioMoraes
from turbolinks-compatibility.
@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)
- Turbolinks not working with google ads or LiveHelpNow
- Google Tag Manager HOT 5
- Facebook like/share button still disappearing HOT 1
- Marketo munchkin tracker integration request
- Integration with Google TagManager HOT 4
- Happyfox Chat loading problem after language change HOT 4
- Can't find a way to change Facebook language HOT 1
- Loading Javascripts Problem HOT 1
- React Native HOT 1
- Turbolinks 5 compatibility HOT 8
- Should the solutions propose both coffee script and standart js version?
- Segment.com HOT 1
- Olark Hummingbird theme
- New Sharethis implementation and Turbolinks' incompatibility HOT 3
- owlCarousel not Loaded
- Zendesk old and new tab displayed HOT 2
- Turbolink 5 and Google DFP not working
- LiveZilla Compatability
- Using the Freshdesk/Freshdesk Widget with Turbolinks HOT 4
- SaleForce Widget with turbolinks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbolinks-compatibility.