Тосты Bootstrap JS
Классы CSS всплывающих уведомлений
Компонент Toast похож на окно предупреждения, которое отображается только на пару секунд, когда что-то происходит (например, когда пользователь нажимает кнопку, отправляет форму и т. д.).
Учебное пособие по тостам можно найти в нашем учебном пособии по Bootstrap Toast .
Class | Description | Example |
---|---|---|
.toast |
Creates the toast | |
.toast-header |
Creates the toast header | |
.toast-body |
Creates the toast body |
Активировать через JavaScript
Тосты должны быть инициализированы с помощью jQuery: выберите указанный элемент и вызовите toast()
метод.
Пример
<script>
$(document).ready(function(){
$('.toast').toast('show');
});
</script>
Параметры тостов
Параметры можно передавать через атрибуты данных или JavaScript. Для атрибутов данных добавьте имя опции к data-
, как в data-animation=""
.
Name | Type | Default | Description | Try it |
---|---|---|---|---|
animation | boolean | true |
Specifies whether to add a CSS fade transition effect when showing and hiding the toast.
|
|
autohide | boolean | true | Specifies whether to hide the toast by default | |
delay | number | 500 | Specifies the number of milliseconds it will take to hide the toast once it is shown. |
Методы тостов
В следующей таблице перечислены все доступные методы всплывающих уведомлений.
Method | Description | Try it |
---|---|---|
.toast(options) | Activates the toast with an option. See options above for valid values | |
.toast("show") | Shows the toast | |
.toast("hide") | Hides the toast | |
.toast("dispose") | Hides and destroys the toast |
Тост События
В следующей таблице перечислены все доступные всплывающие уведомления.
Event | Description | Try it |
---|---|---|
show.bs.toast | Occurs when the toast is about to be shown | |
shown.bs.toast | Occurs when the toast is fully shown (after CSS transitions have completed) | |
hide.bs.toast | Occurs when the toast is about to be hidden | |
hidden.bs.toast | Occurs when the toast is fully hidden (after CSS transitions have completed) |