Implement "sweet alert" for ajax errors and confirmations
This commit is contained in:
parent
986b3a95a8
commit
dfdb6259d8
|
|
@ -2,6 +2,44 @@
|
|||
* October General Utilities
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implement "Sweet Alert"
|
||||
*/
|
||||
|
||||
$(window).on('ajaxErrorMessage', function(event, message){
|
||||
|
||||
swal({
|
||||
title: '',
|
||||
text: message,
|
||||
type: 'error',
|
||||
confirmButtonClass: 'btn-danger'
|
||||
})
|
||||
|
||||
// Prevent the default alert() message
|
||||
event.preventDefault()
|
||||
|
||||
})
|
||||
|
||||
$(window).on('ajaxConfirmMessage', function(event, message){
|
||||
|
||||
swal({
|
||||
title: '',
|
||||
text: message,
|
||||
type: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonClass: 'btn-primary'
|
||||
}, function(isConfirm){
|
||||
isConfirm
|
||||
? event.promise.resolve()
|
||||
: event.promise.reject()
|
||||
})
|
||||
|
||||
// Prevent the default confirm() message
|
||||
event.preventDefault()
|
||||
return true
|
||||
|
||||
})
|
||||
|
||||
/*
|
||||
* Path helpers
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue