0

At the top of the user's profile I have this button:

<%= button_to 'Make a detailed enquiry', user_path(@user), :class=>"enquirySection", :method => :get %>

Then at the very bottom of the page I am rendering a form in which the viewer can make an enquiry:

    <div class="enquirySection">
      <%= render "enquiries/form" %>
    </div>

I want the user to be scrolled down to this form when (s)he clicks on the button so I added the ":class=>"enquirySection"" and "div class="enquirySection"". It doesn't work.

I tried something similar to that but I think it does not related to my case.

Any clue of how is this done in Rails with button_to?

Thank you.

Community
  • 1
  • 1

1 Answers1

1

You don't need a class, but an id

try

<%= button_to 'Make a detailed enquiry', user_path(@user, anchor: :enquirySection), :method => :get %>

or simply

<%= link_to 'Make a detailed enquiry', user_path(@user, anchor: 'enquirySection) %>

and then

<div id="enquirySection">
 <%= render "enquiries/form" %>
</div>

would do the job.

xlembouras
  • 8,215
  • 4
  • 33
  • 42