Comments (6)
Gon can be used in a handful of different ways, so it's hard for me to suggest anything with confidence. How are you using it in your application?
from turbolinks-compatibility.
I set a handful of variables I want access to on every request (for some analytics libs) in a before filter in the application controller. Then in a few spots in the regular workflow of the app I set a variable here or there in a controller action directly.
The vars from the application_controller before filter come through fine because they're known at the beginning of the request and have the benefit of a full page load. The variable from say a show action of a controller giving me that object's id is what I'm running into as an issue with the suggested setup of gon.
I'm experimenting with putting the gon initialization just inside the opening body tag and loading my main javascript include tag at the bottom of the body (just before my analytics code) instead of the more traditional setup of putting the js include tag in the head and having the gon initialization as the first thing in the head (above the aforementioned js include tag). Hopefully I'm headed in the right direction, thoughts?
from turbolinks-compatibility.
Yeah, I think you've got the right idea. You shouldn't move your main javascript to the body, though, because it will run on every page change. Provided you're not attempting to access the gon data before DOM ready, I would think that just moving the gon initialization inside the body would be sufficient.
from turbolinks-compatibility.
Was there ever a proper solution to this? I'm experiencing the exact same thing at the moment
from turbolinks-compatibility.
@geoffw8 right now what is working for me is including gon as the first thing inside the body. I actually also have it in the head too (which probably isn't necessary and I'll test removing it this week).
from turbolinks-compatibility.
@jondkinney thanks for getting back to me. You know, I tried that but I kept getting gon is not defined so what I WILL try is having it in both the header and the body. Thats might be the trick
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.