Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ConfirmationBox
App.ConfirmationBox =
defaults:
title: 'Warning'
message: 'Are you sure?'
cancel_btn: 'Cancel'
confirm_btn: 'Confirm'
confirmDialog: (element) ->
title = element.data('title') || @defaults['title']
message = element.data('confirm') || @defaults['message']
cancel_btn = element.data('cancel-btn') || @defaults['cancel_btn']
confirm_btn = element.data('confirm-btn') || @defaults['confirm_btn']
element.data('confirm', null)
bootbox.confirm
title: title
message: message
buttons:
cancel:
label: cancel_btn
className: 'btn-default'
confirm:
label: confirm_btn
className: 'btn-danger'
callback: (result) ->
element.trigger 'click.rails' if result
element.data('confirm', message)
return
$(document).on 'confirm', (event) ->
element = $(event.target)
App.ConfirmationBox.confirmDialog(element)
false
<div class="btn-group">
<%= link_to 'Eliminar', product, class: 'btn btn-danger', method: :delete,
data: { confirm: 'Se eliminará el producto junto a todos sus modelos de forma permanente',
'disable-with' => 'Eliminando...', title: '¿Eliminar Producto?',
'confirm-btn' => 'Si, eliminar producto', 'cancel-btn' => 'No, no eliminar'} %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.