Convert Form to Link

26 views
Skip to first unread message

Jan Yo

unread,
Apr 4, 2014, 12:10:22 PM4/4/14
to rubyonra...@googlegroups.com
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 ?

--
Posted via http://www.ruby-forum.com/.

Дмитро Бігняк

unread,
Apr 5, 2014, 5:23:46 AM4/5/14
to rubyonra...@googlegroups.com
May be you searched this?
<%= link_to 'Search', "#", :onclick=>"$('.search_form').submit()" %>

Walter Lee Davis

unread,
Apr 5, 2014, 9:20:51 AM4/5/14
to rubyonra...@googlegroups.com
The Rails link_to helper includes the :method => :post option, which will invoke an unobtrusive JavaScript method to generate a form out of your link and send it that way.

Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b32eb21c-e55b-4393-b080-0a8e5db40f1e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages