Bootstrap JS Toasts
คลาส CSS ของขนมปัง
คอมโพเนนต์ Toast เป็นเหมือนกล่องแจ้งเตือนที่แสดงเพียงไม่กี่วินาทีเมื่อมีบางอย่างเกิดขึ้น (เช่น เมื่อผู้ใช้คลิกปุ่ม ส่งแบบฟอร์ม เป็นต้น)
สำหรับบทแนะนำเกี่ยวกับ Toasts โปรดอ่านBootstrap Toast Tutorialของเรา
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) |