Rails is not passing the “commit” button parameter

前端 未结 5 941
醉梦人生
醉梦人生 2021-02-08 05:27

Reinstalling a Rails app on a new server. Part of the app can fork in one of two directions based on the button the user selects. This part isn\'t working, and when I look at

5条回答
  •  Happy的楠姐
    2021-02-08 06:03

    Had a simular problem with a disable-button-on-submit feature. We solved it by adding a hidden input field with the same name and value before submitting the form.

    function disableButtonAndSubmit()
    {
      var input = $("").attr("name", $(this)[0].name).attr("value", $(this)[0].value);
      $(this).closest('form').append(input);
      $(this).attr('disabled', 'disabled').html('Loading…');
      $(this).closest('form').submit();
    }
    
    $('#somewhere button').click(disableButtonAndSubmit);
    

提交回复
热议问题