Last active
March 14, 2017 18:48
-
-
Save nicogaldamez/d4a363f60dc881b50fd382d20b659ff9 to your computer and use it in GitHub Desktop.
ConfirmationBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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