這是我new.js.erb調用渲染功能行如何傳遞一個變量來渲染?
$('.node_container').append("<%= escape_javascript(render(@care_point, :locals => {:care_map => @care_map}))%>");
給出錯誤信息:
ActionView::Template::Error (undefined local variable or method `care_map'
我的部分_care_point.html.erb:
<%= link_to 'Delete', [care_map, care_point], :confirm => "Are you sure?", :method => :delete, :remote => true, :class => 'delete' %>
這是@care_map在你的控制器中定義的嗎? (我的意思是在format.js塊) – bor1s
來傳遞'locals'變量,你必須使用'render:partial => ...'而不僅僅是'render @ var' – apneadiving
@apneadiving - 把它放在一個答案中: ) – willcodejavaforfood