JQuery event handler for displaying hidden form in Rails
I have never used JQuery in Rails before but need it to make a button
clickable so that it opens up a form(which is currently hidden) on
clicking it -- The problem im having is in specifically using it in rails
as I have no idea how and where to include the jquery code (so far I have
installed the jQuery gems)
This the code in my view:
<td>
<div class="file_description"><%= object.metadata['description']%>
<button type="button" class="btn btn-default
edit_description">Edit</button></div>
<div class="file_description_update">
<%= form_tag({:action => 'update_file_info'}, multipart: true)
do %>
Update File Description: <%= text_area_tag :description %>
<%= hidden_field_tag :s3_path, file %>
<%= hidden_field_tag :prefix, @prefix %>
<%= submit_tag 'Submit' %> </td> <br />
<% end %>
</div>
</td>
Right now I have hidden the div.file_description_update class
This is the code I could possibly use for jquery:
var hiddenBox = $( "div.file_description_update" );
$( "button.edit_description" ).on( "click", function( event ) {
hiddenBox.show();
});
Can someone please let me know if the jquery I am using for this purpose
is correct and where and how I can include the jquery code within my rails
app (which file?)
No comments:
Post a Comment