Reputation: 3337
In my Rails app I have a modal that pops up when trying to close an object (in this case a call). The modal pops up with a standard Rails link_to like so:
<%= link_to "Close Call #{call.incident_number}", close_call_path(call), :method => :post, :class => 'btn btn-danger btn-large btn-block' %>
In form objects I'm able to disable the submit button but setting the data attribute of disable_with, but Im not sure if this option is available in the link_to helper.
<%= f.button "Update Unit", class: 'btn btn-info', data: {disable_with: "<i class='icon-spinner'></i>Updating..."} %>
My goal is to prevent duplication clicks of the button once the action hits the controller.
Upvotes: 0
Views: 2612
Reputation: 118271
As per the link_to
documentation, you can use the option disable_with
as data
attribute.
:disable_with
- Value of this parameter will be used as the value for a disabled version of the submit button when the form is submitted. This feature is provided by the unobtrusive JavaScript driver.
Upvotes: 1