我正在尝试使用带有rails_admin gem的ajax,但我无法使用它。
创建了_product.html.erb
,index.html.erb
,index.js.erb
在 index.html.erb
中<div id="products"><%= render "products" %> </div>
在 index.js.erb
中$("#products").html("<%= escape_javascript(render("products")) %>");
答案 0 :(得分:1)
听起来你需要传递局部变量:
Rails 4 - passing variable to partial
类似的东西:
$("#products").html("<%= escape_javascript render :partial => "products", locals: { product: @products } %>");
取决于您的其余代码。