Skip to content

Instantly share code, notes, and snippets.

@peterfication
Last active November 28, 2017 15:36
Show Gist options
  • Save peterfication/675528043e4b45262a8ae454af4d7255 to your computer and use it in GitHub Desktop.
Save peterfication/675528043e4b45262a8ae454af4d7255 to your computer and use it in GitHub Desktop.
Rails SweetAlert confirm Webpacker
import Rails from 'rails-ujs';
const handleConfirm = () => {
// Do your thing
}
// Add event listener before the other Rails event listeners like the one
// for `method: :delete`
Rails.delegate(document, 'a[data-confirm-swal]', 'click', handleConfirm)
Rails.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment