I have a section on my page where users can add a ‘project’. After they submit the ‘project’ form, a new project form field will appear beside the old project.
Basically I have a ‘project’ form in a partial erb in rails. On the button click, if the form fields are valid, I want to append a ‘project’ partial to parent div. Trying the below code, but instead of actually rendering the view - I get the literal HTML code showing up on the page (<%= render partial: ‘projects/project’) %>)
if (projectUrl && projectName && projectDescription) {
$.ajax({
type: "POST",
url: '/projects',
data: { project: { name: projectName, description: projectDescription, url: projectUrl, user_id: projectUser } },
success: function(data) {
$('.projects').append("<%= render partial: 'projects/project') %>").html_safe;
return false;
},
error: function(xhr, textStatus, error){
console.log(xhr.statusText);
console.log(textStatus);
console.log(error);
return false;
}
});
}