[英]Rails ERB Inside Javascript
I'm trying to use some View instance variables inside Javascript . 我试图在Javascript中使用一些View实例变量。
My JS file is included in the head tag of my HTML . 我的JS文件包含在HTML的head标签中。 And it's a *.js file in assets/javascript .
这是Assets / javascript中的* .js文件。
When I try to... 当我尝试...
console.log(<%= @some_instance_variable %>)
... I get syntax error. ...我收到语法错误。 And if I try to...
如果我尝试...
console.log('<%= @some_instance_variable %>')
... the output is just the string <%= @some_instance_variable %> . ...输出只是字符串<%= @some_instance_variable%> 。 How can I do to obtain the instance variable's actual value?.
如何获取实例变量的实际值? I'd really appreciate any help!.
我将非常感谢您的帮助!
Regards!. 问候!。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.