To integrate the widget on platforms that use Turbo links using Ruby on Rails, follow the steps below:
- In the Ruby on Rails project, open your JavaScript file.
- Add the following in the file:
document.addEventListener('turbolinks:before-visit', () => { document.querySelector("html").removeAttribute("data-uw-w-loader");
window._userway = false
}); ['turbolinks:load', 'turbolinks:visit'].forEach((evt) => {
document.addEventListener(evt, () => {
(function(d) {
var s = d.createElement("script");
s.setAttribute("data-account", "YOUR WIDGET CODE HERE");
s.setAttribute("src", "https://cdn.userway.org/widget.js");
(d.body || d.head).appendChild(s);
})(document)
})
})
The "data-account"
must be updated with your accountID:
How to get your widget code, If you're using Turbo and not Turbo links, change from "Turbolinks" to "turbo" on the code.