Tostadas Bootstrap JS
Brindar clases de CSS
El componente Toast es como un cuadro de alerta que solo se muestra durante un par de segundos cuando sucede algo (es decir, cuando el usuario hace clic en un botón, envía un formulario, etc.).
Para obtener un tutorial sobre tostadas, lea nuestro Tutorial de Bootstrap Toast .
Class | Description | Example |
---|---|---|
.toast |
Creates the toast | |
.toast-header |
Creates the toast header | |
.toast-body |
Creates the toast body |
Activar a través de JavaScript
Los brindis deben inicializarse con jQuery: seleccione el elemento especificado y llame al toast()
método.
Ejemplo
<script>
$(document).ready(function(){
$('.toast').toast('show');
});
</script>
Opciones de tostadas
Las opciones se pueden pasar a través de atributos de datos o JavaScript. Para los atributos de datos, agregue el nombre de la opción a data-
, como en 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. |
Métodos de tostadas
La siguiente tabla enumera todos los métodos de tostado disponibles.
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 |
Eventos de brindis
La siguiente tabla enumera todos los eventos de brindis disponibles.
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) |