我有这个命令,我知道语法有点偏离
page << "$('.places').append('<%= escape_javascript(render(:partial => 'contact', :locals => {:contact => @contact, :something => @something, :checked => false, :sale => @sale.item.to_s})) %>');"
这是我需要做的基本调用,但我知道js.rjs文件的语法错误....有没有办法将其转换为该格式
答案 0 :(得分:1)
使用原型(Rails 2.3)
page.select(".places").each do |element, index|
page.insert_html :bottom, element, :partial => 'contact', :locals => {:contact => @contact, :something => @something, :checked => false, :sale => @sale.item.to_s}
end
使用jQuery(Rails 3)
$(".places").append("<%= escape_javascript render 'contact', :locals => {:contact => @contact, :something => @something, :checked => false, :sale => @sale.item.to_s} %>");