• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Ruby Rails form

I have an empty form into a link.  That is instead of having a button initiate a get request, do it with a link.

The form looks like this:

<%= form_tag somethpath(@data), method: get, :remote => true, :'data-attr' => @data.id do %>
  <%= submit_tag "Search" %>
<% end %>

Is there an equivalent way to do this using link_to ?
0
lcor
Asked:
lcor
  • 3
2 Solutions
 
Andrew DoadesIT TechnicianCommented:
Do you want to replace the submit button with a link_to link?
0
 
lcorAuthor Commented:
yes
0
 
Andrew DoadesIT TechnicianCommented:
You'll have to use JavaScript for this then

<%= link_to 'Save', "#", :onclick=>"$('.search_form').submit()" %>

Open in new window

0
 
Andrew DoadesIT TechnicianCommented:
<%= link_to 'Search', "#", :onclick => "$('#form_id').submit()" %>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now