I have a Rails 4 app. I define a variable var a = 1
in app/assets/javascripts/a.js
. Then I'd like to use that variable in app/assets/javascripts/b.js
, but whenever I use a
in b.js
, it says it's undefined. Why?
Thanks.
Javascript Variables in Rails Assets
196 views Asked by user2725109 At
2
as @leito said your variable is local one and needs to be declared global
use
window.classie
instead ofvar classie