我正嘗試在手風琴中預先打開div。我正在相應的控制器中設置實例變量@expanded_section
。我想使用的jQuery的UI手風琴這樣的使用再培訓局的active
參數值在我的CoffeeScript文件中的assets/javascripts
文件夾CoffeeScript與ERB錯誤
$(".sections").accordion({
active: <%[email protected]_section%>,
header: "h4",
collapsible: true,
heightStyle: "content" }).sortable({
axis: "y",
handle: "h4",
update: ->
$.post($(this).data('update'), $(this).sortable('serialize'))
})
但我收到以下錯誤:
Error: Parse error on line 60: Unexpected ','
(在/home/steve/dev/rails/Survey/app/assets/javascripts/surveyys.js.coffee.erb)
line 60
是active: <%[email protected]_section%>,
如果我做一個@expanded_section
電話to_i
它呈現active:0
。
但是,當我從控制器打印@expanded_section
值到控制檯它打印正確的預期值。
請幫忙。
如何在haml中執行window.expanded_section? – 2013-02-23 04:47:03
@stevanity:對不起,不知道,不是HAML的傢伙。谷歌搜索應該有所幫助。 – 2013-02-23 04:55:56
好吧np :)我用了一個javascript過濾器。無論如何。在我的js文件,我得到'window.expanded_section'就像是:( – 2013-02-23 04:57:53