我尝试用Ajax添加所有项目,但视图一直不刷新。当我强制刷新时,新产品却出现在了列表中。下面是代码:http://pastie.org/1533605哪里出问题了?我用的是 jquery。
Try:
$("#products").html("<%= escape_javascript(render(:partial => "products")) %>");
And I guess you'd better do $("#products").append(...)
so that ou keep the former content instead of replacing it.
To conclude, consider keeping this kind of behavior on the client side, look at: http://railscasts.com/episodes/197-nested-model-form-part-2
okay, i figure it out, some problem with my markup sry of this stupid question
$('<%= escape_javascript(render(:partial => @product))%>').insertBefore('.height'); that was final solution