File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -302,21 +302,24 @@ wouldn't work. You can read about this in common usage above.
302302Now you can use gon for sending your data to js from anywhere!
303303
304304It works just as simple ` gon ` but you need to write ` Gon.global ` instead of ` gon ` in your ruby code,
305- ` gon.global ` in javascript and it will not clear self after each request. All other things the same.
305+ ` gon.global ` in javascript and it will not clear self after each request. All other things remain the same.
306306
307- For example I want to tell anybody my application session secret token :) Now with Gon.global it's easy!
307+ For example I want to set start data into gon, which will be there before I clear it.
308308
309- ` config/initializers/secret_token.rb `
309+ Maybe some configuration data or url address which should be present on each page with ` include_gon ` helper in head.
310+
311+ Now with Gon.global it's easy!
312+
313+ ` config/initializers/some_initializer.rb or any file where you can reach Gon constant `
310314
311315``` ruby
312- GonTest ::Application .config.secret_token = " You can't see my token"
313- Gon .global.secret_token = " You can't see it I said"
316+ Gon .global.variable = ' Some data'
314317```
315318
316319` in some js which can reach window.gon variable `
317320
318321``` javascript
319- alert (gon .global .secret_token )
322+ alert (gon .global .variable )
320323```
321324
322325Thats it!
You can’t perform that action at this time.
0 commit comments