Follow these steps to integrate the widget on platforms that use Turbolinks using Ruby on Rails:
- Step 1: In the Ruby on Rails project, open your JavaScript file.
- Step 2: 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); }); });
Note: The "data-account"
must be updated with youraccountID:
If you’re using Turbo and not Turbolinks, change from “Turbolinks” to “turbo” in the code.