我正在尝试将Ajax与rails_admin gem一起使用,但无法使用它。

创建了_product.html.erbindex.html.erbindex.js.erb

在index.html.erb中

<div id="products"><%= render "products" %> </div>


在index.js.erb中

$("#products").html("<%= escape_javascript(render("products")) %>");

最佳答案

听起来您需要传递局部变量:

Rails 4 - passing variable to partial

就像是:

$("#products").html("<%= escape_javascript render :partial => "products", locals: { product: @products } %>");


取决于其余的代码。

关于javascript - 我正在使用Rails Admin gem,但是如果不重新加载页面就无法发布产品,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41727831/

10-10 00:28
查看更多