Skip to content

Instantly share code, notes, and snippets.

@francois-blanchard
Last active September 26, 2016 12:38
Show Gist options
  • Save francois-blanchard/a67b9a3e742e8f9bd3f4ac365c8b6cd5 to your computer and use it in GitHub Desktop.
Save francois-blanchard/a67b9a3e742e8f9bd3f4ac365c8b6cd5 to your computer and use it in GitHub Desktop.
Disable button with ActionView helper

Disable button with ActionView helper

It's simple

Just have to add disable_with param like this :data => { disable_with: false }

submit_tag "Complete sale", data: { disable_with: "Submitting..." }
# => <input name="commit" data-disable-with="Submitting..." type="submit" value="Complete sale" />

Works with button_tag, link_to, button_to

There is a known issue that disable_with does not work link_to for some browsers.

It's more fun with animations 😄

link_to "Complete sale", url_path, data: { disable_with: "<i class='fa fa-refresh fa-spin'></i> Synchronisation en cours ..." }

How to animate icon with font awesome ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment