File tree Expand file tree Collapse file tree 3 files changed +10
-11
lines changed
Expand file tree Collapse file tree 3 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,8 @@ If you need to send some data to your js files and you don't want to do this wit
99``` erb
1010<head>
1111 <title>some title</title>
12- <%= gon_variables %>
13- <%= javascript_include_tag 'http://code.jquery.com/jquery-1.6.min.js' %> <!-- include jquery -->
14- <%= include_gon_js %> <!-- http://gaziev.com/files/gon.js -->
12+ <%= include_gon %>
13+ <!-- include your action js code -->
1514 ...
1615```
1716
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ def self.included base
55 end
66
77 module InstanceMethods
8- def include_gon_js
9- javascript_include_tag 'http://gaziev.com/files/gon.js'
10- end
11-
12- def gon_variables
8+ def include_gon
139 data = Rails . cache . read ( 'gon_variables' ) || { }
1410
15- '<gon style="display:none">' + data . to_s . gsub ( '=>' , ' : ' ) +
16- '</gon>'
11+ script = "<script>function Gon(){"
12+ data . each do |key , val |
13+ script += "this." + key . to_s + "'" + val . to_s + "';"
14+ end
15+ script += "}; var Gon = new Gon()</script>"
16+ script . html_safe
1717 end
1818 end
1919
Original file line number Diff line number Diff line change 11module Gon
2- VERSION = '0.1.1 '
2+ VERSION = '0.2.0 '
33end
You can’t perform that action at this time.
0 commit comments