Rails 4: Disable submit button after click

前端 未结 5 2090
天涯浪人
天涯浪人 2020-12-15 21:54

I have a form_tag(foo_path(@foo), remote: true, id: \'foo-form\' form and a submit button submit_tag (\"Submit\", :id => \"foo-submit\")

<
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 22:25

    You use CoffeeScript to do something like these lines:

    jQuery ->
      $('.theform').submit ->
        $('input:submit').attr("disabled", true)
    

    This disables the form submit button when the form with class="theform" is submitted. Depending on your need you adjust this to fit with your class/id for the form.

提交回复
热议问题