How can I pass the user_id on escape javascript while render on jquery?
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>
You could pass your partial to javascript as:
$("#user tr:last").after("<%= escape_javascript(render :partial => 'user_item', :locals => {:user_item => User.find(@user_id)}) %>")
Where @user_id would be the user you wanted to load. This would render the partial on page load though, so each click of #addPerson would load the same partial with the same @user_id.
If that's not your intention you could try using a multiple record form or create a new partial with javascript or an ajax call to your server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With