Petya petrov
Petya petrov

Reputation: 2213

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 wrong? im using jquery

Upvotes: 1

Views: 1289

Answers (2)

Petya petrov
Petya petrov

Reputation: 2213

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

Upvotes: 1

apneadiving
apneadiving

Reputation: 115511

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

Upvotes: 0

Related Questions