im trying add item with ajax, all work, except the view doesnt refresh, when i force refresh, new product in the list, here is code http://pastie.org/1533605 what's wro开发者_JAVA技巧ng? im using jquery
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
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
精彩评论