samedi 11 juin 2016

Disable link_to button in Rails after submit to prevent duplication submission

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.

Aucun commentaire:

Enregistrer un commentaire