For Bootstrap toasts please refer to its documentation.
In Ace there's an aceToaster function that creates a toast element and displays it:
var newToast = $.aceToaster.add({
placement: 'tr',
title: 'This is a sample notice!',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
icon: '<i class="far fa-lightbulb fa-2x text-blue ml-2 mr-1"></i>',
className: 'bgc-white-tp2 brc-secondary-tp4 rounded-sm',
headerClass: 'bg-transparent border-0 text-120 text-dark-m3 font-bolder',
bodyClass: 'pt-0'
});
The following options are available:
Is an HTML string representing classname of an element that will be inserted as progress bar for toast
$.aceToaster.add({
progress: 'position-bl bgc-black-tp6 py-2px m-1px'
// bgc-black-tp6 color
// position-bl means will be on bottom left
// py-2px means height will be 4px ...
...
})
If true, direction of progress will be reversed
$.aceToaster.add({
progress: 'position-bl bgc-white-tp4 py-2px m-1px',
progressReverse: true
});
which can have the following values:
tortoptoptctop-centertrtop-righttltop-leftborbottombottombcbottom-centerbrbottom-rightblbottom-leftrorrigtrightrcright center (middle)lorleftleftlcleft center (middle)corcentercenter
Toast element will appear below navbar
Specify width
Toast element's class names
Toast header's class names
Title. Can be a string or a function. No sanitization is performed
Title's class names
Toast content/body. Can be a string or a function. No sanitization is performed
Body's class names
Optional image
Optional image class name. If there's no image, but there's an icon, will be used for the icon.
Optional icon
Default is true and display a close button.
Close button's class names
Default is true and removes the toast element from DOM after it is hidden
Default is 2500 and toast element will be hidden after that amount of time
If true it don't autohide and should be closed using close button or called via Javascript.
Same as autohide:false
Disables/enables animation when showing/hiding toast
The toast element's template. Default is:
<div class="toast">
<div class="d-flex">
<div class="toast-image"></div>
<div class="toast-main">
<div class="toast-header"></div>
<div class="toast-body"></div>
</div>
</div>
</div>
Can be false or true. Sets the aria-live and role attributes of the toast element.
You can also have a toast element in your HTML and use aceToaster function to show it:
<div id="mytoast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
...
</div>
<div class="toast-body">
...
</div>
</div>
$('#mytoast').aceToaster({
placement: 'tr'
});
Hides and removes all toast elements.
Two options are available:
- If
placementis specified, only those in that particular placement will be removed - If
instantis true, toast will be removed instanly, otherwise it will first fade out
$.aceToaster.removeAll() // remove all
$.aceToaster.removeAll('tr') // remove all toasts in top right position
$.aceToaster.removeAll(null, true) // remove all toasts instantly
Just hides the toasts
Hides and removes a toast:
var newToast = $.aceToaster.add({ ... })
$.aceToaster.remove(newToast)
$.aceToaster.remove(4) // removes #ace-toaster-item-4'
Just hides a toast
Triggered before a toast is created
Triggered after a toast is created
Triggered before all toasts are to be hidden using removeAll function
$(document).on('add.ace.toaster', function(e) {
// e.preventDefault()
// e.target is the new toast
})
$(document).on('added.ace.toaster', function(e) {
// e.target is the new toast
})
$(document).on('clear.ace.toaster', function(e, info) {
// e.preventDefault()
// info.remove (remove or just hide)
// info.placement ('all' or for example 'tr')
})