I have a Projects controller and in the “new.html.erb” view i’ve the following code:
<div class="row">
<%= form_for @project, remote: true do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :description %>
<%= f.text_field :description %>
<%= f.submit "Add Project", class: "btn btn-primary"%>
<% end %>
</div>
<p id= "test">Hello</p>
When i click on the submit button i know that is called the “create” action in the Projects controller:
def create
respond_to do |format|
format.html{ redirect_to new_project_path}
format.js
end
end
I have created the create.js.erb file to handle the ajax request:
("#test").hide()
Why the
<p id= "test">Hello</p>
in the new.html.erb doesn’t hide?
What is the problem?
Thanks all for yours answers
If you are using jquery then you left the
$in front of the js script.