开发者

add item with ajax

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜