您可以看到this reference,但如果此链接已被删除,请阅读以下说明:
使用单行 JavaScript 调用 id 为 myModal 的模式:
$('#myModal').modal(options)
选项
选项可以通过数据属性或 JavaScript 传递。对于数据属性,将选项名称附加到 data-,如 data-backdrop=""。
|-----------|-------------|--------|---------------------------------------------|
| Name | Type | Default| Description |
|-----------|-------------|--------|---------------------------------------------|
| backdrop | boolean or | true | Includes a modal-backdrop element. |
| | the string | | Alternatively, specify static for a |
| | 'static' | | backdrop which doesn't close the modal |
| | | | on click. |
| | | | |
| keyboard | boolean | true | Closes the modal when escape key is pressed.|
| | | | |
| focus | boolean | true | Puts the focus on the modal when initialized|
| | | | |
| show | boolean | true | Shows the modal when initialized. |
|-----------|-------------|--------|---------------------------------------------|
方法
异步方法和转换
所有 API 方法都是异步的并开始一个转换。他们回来了
转换开始但在结束之前立即发送给调用者。
此外,对过渡组件的方法调用将是
忽略。
See our JavaScript documentation for more information.
.modal(选项)
将您的内容激活为模式。接受一个可选的选项对象。
$('#myModal').modal({
keyboard: false
})
.modal('toggle')
手动切换模式。 在模态框实际显示或隐藏之前返回给调用者(即在 shown.bs.modal 或 hidden.bs.modal 事件发生之前)。
$('#myModal').modal('toggle')
.modal('show')
手动打开一个模式。 在模态框实际显示之前返回给调用者(即在 shown.bs.modal 事件发生之前)。
$('#myModal').modal('show')
.modal('hide')
手动隐藏模式。 在模态框实际隐藏之前返回调用者(即在 hidden.bs.modal 事件发生之前)。
$('#myModal').modal('hide')
.modal('handleUpdate')
如果模态框在打开时的高度发生变化(即出现滚动条时),请手动重新调整模态框的位置。
$('#myModal').modal('handleUpdate')
.modal('dispose')
销毁一个元素的模态。
活动
Bootstrap 的模态类公开了一些用于连接模态功能的事件。所有模态事件都在模态本身触发(即在 ** 处)。
类型说明
|----------------|--------------------------------------------------------------|
| Event Type | Description |
|----------------|--------------------------------------------------------------|
| show.bs.modal | This event fires immediately when the **show** instance |
| | method is called. If caused by a click, the clicked element |
| | is available as the **relatedTarget** property of the event. |
| | |
| shown.bs.modal | This event is fired when the modal has been made visible to |
| | the user (will wait for CSS transitions to complete). If |
| | caused by a click, the clicked element is available as the |
| | **relatedTarget** property of the event. |
| | |
| hide.bs.modal | This event is fired immediately when the **hide** instance |
| | method has been called. |
| | |
| hidden.bs.modal| This event is fired when the modal has finished being hidden |
| | from the user (will wait for CSS transitions to complete). |
|----------------|--------------------------------------------------------------|
$('#myModal').on('hidden.bs.modal', function (e) {
// do something...
})