Reputation: 1934
I am trying to show div by clicking on a button form. I know its wrong just not to sure what to write, and should i write it on my javascript page or just in the view.
<%= submit_tag "Next Step", :type => 'button', :onclick => '$('#devregothinf').hide();' %>
<div id="devregothinf">
<h2>General Information</h2>
<%= render 'geninfor_step', form: f %>
</div>
i am getting an error as follow
syntax error, unexpected $end, expecting ')'
Upvotes: 0
Views: 49
Reputation: 16629
You could do something like this
view (app/views/home.html.erb)
<%= link_to 'Next Step', 'home/next_step', :remote => true %>
<div id="devregothinf">
controller (app/controllers/home_controller.rb)
def next_step
<your code>
respond_to do |format|
format.js
end
end
*view (js.erb) (app/views/next_step.html.erb)*
$("#devregothinf").html("<%= raw escape_javascript(render(:partial => 'form')) %>")
*view (app/views/_form.html.erb)*
Your form partial
HTH
Upvotes: 1
Reputation: 1305
Write as following:
<span onclick = "$('#devregothinf').slideToggle('slow');"> Next Step </span>
<div id="devregothinf" style="display:none;">
<h2>General Information</h2>
<%= render 'geninfor_step', form: f %>
</div>
Upvotes: 1
Reputation: 84
If you're trying to get it to show and not hide, you just need to change $('#devregothinf').hide(); to $('#devregothinf').show();
Upvotes: 1