Implement "sweet alert" for ajax errors and confirmations

This commit is contained in:
Samuel Georges 2014-12-15 17:50:15 +11:00
parent 986b3a95a8
commit dfdb6259d8
1 changed files with 38 additions and 0 deletions

View File

@ -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
*/