Reputation: 41
I am new to using jQuery and currently implementing a feature where a form partial, which creates a new journal for the user upon submission, will appear upon clicking a button. I followed the tutorial here (https://www.pair.com/support/kb/how-to-use-jquery-to-show-hide-a-form-on-click/#setting-up-jquery-for-toggle) and was able to successfully show/ hide the form partial on click.
However, the submit feature for my form is not working while it works before. A new journal is not created and the link becomes something like this: http://localhost:3000/profile?utf8=%E2%9C%93&authenticity_token=QCVIKK%2Bti%2BVFHCuo5zdlY4p2zT1mlxxkzATmnz%2Fiewudn%2BEiP2QhgZZ%2F5P9LSF5drunljfNqINSEnllIscfzWw%3D%3D&journal%5Btitle%5D=Hello&journal%5Bprivate%5D=true&commit=Create. I tried looking at previous forum answers but none of them helped. Any help would be greatly appreciated!
Here is some of the relevant code:
<button type="button1" id="journal-button">Create new journal</button>
<form id="journal-form">
<%= render 'shared/journal_form' %>
</form>
Form partial
<%= form_for @journal do |f| %>
<div>
<%= f.text_area :title, placeholder: "New Journal", :rows => 1, style: 'width:70%'%>
</div>
<div class="select-field">
<%= f.label :private, 'Privacy mode' %>
<%= f.select :private, [['Private', true], ['Public', false]] %>
</div>
<%= f.submit "Create", class: "btn btn-primary" %>
<% end %>
Upvotes: 0
Views: 154
Reputation: 41
I figured it out, I'm not supposed to use <form>
. It works when I simply change it to <div>
.
Upvotes: 1