如何传递变量进行渲染?
这是我的 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' %>
This is the line in my new.js.erb that calls the render function
$('.node_container').append("<%= escape_javascript(render(@care_point, :locals => {:care_map => @care_map}))%>");
Gives error message:
ActionView::Template::Error (undefined local variable or method `care_map'
for my partial _care_point.html.erb:
<%= link_to 'Delete', [care_map, care_point], :confirm => "Are you sure?", :method => :delete, :remote => true, :class => 'delete' %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要传递局部变量,您必须使用
而不仅仅是:
请参阅文档此处,段落
3.4.4
。To pass locals variables, you must use
and not the mere:
See doc here, para
3.4.4
.