views:

65

answers:

1

render :partial generates only one time on escape_javascript

eg

<script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $("#addPerson").click(function(){
           $("#user tr:last ").after("<%= escape_javascript(render :partial => 'user_item', :locals =>{:user_item => User.new}) %>");
                   return false;
        });  

    });
</script>

and I have checked object_id in the user_item partial file it is showing same object_id until saving and saves only last item.

<%= user_item.object_id %>

which results

12354

every time. Please help me to solve this problem.

A: 

it's because the partial is render only once time.

The HTML file is generate only one time. When you call this Javascript function, it don't call the partial because it's already generate.

If you want a new generation each time. You need made a server call with your user_id and get the HTML in return.

shingara
can u pls post some example code for server call.thanks for ur response
chandramouli
can you speak in complete english too ?
shingara