Hide form until button is clicked - Ruby on Rails
I have a content submission form on the home page of my app.
I would like to have it be hidden until a user clicks "submit an idea", at which point, the form should appear below the submit button.
I'm basing this off of the model used for replies/comments on Reddit, but I can't qu开发者_开发百科ite figure it out.
I'd imagine it involves jQuery, but I am terrible with jQuery, which is why I need your help.
Thanks a lot in advance.
You can do it with jQuery.
$(document).ready(function() {
$('#form_id').hide(); //Initially form wil be hidden.
$('#button_id').click(function() {
$('#form_id').show();//Form shows on button click
});
});
Hide the form when the page loads:
$('#my-form').hide();
and show it when a button is clicked:
$('#my-button').click(function() { $('#my-form').show() });
精彩评论