Submit Rails 4 form with link instead of button

后端 未结 3 1721
感动是毒
感动是毒 2021-02-04 17:12

I see some issues similar but they seem contrived and mostly for previous versions of Rails.

What is the simplest way to submit a form with an anchor tag (link) instead

3条回答
  •  轮回少年
    2021-02-04 17:47

    This is so simple:

    Then:

    <%= f.submit '', :class => "hidden", :id => 'form_submit_button' %>
    content_tag(:a, 'Submit', :name => 'submit', :id => 'submit_link')
    

    and in JS:

    $(document).ready(function() {
        $(document).on("click","#submit_link",function() {
            $('#form_submit_button').click();
        });
    });
    

    I am not sure about exact sytax so there might be some syntax error. Feel free to ask for more help.

提交回复
热议问题