Sự kiện đóng phương thức Bootstrap React

Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, tiền đình ở eros

Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor

Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla

Plugins can be included individually (using Bootstrap's individual

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
4 files), or all at once (using
var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
5 or the minified
var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
6)

Using the compiled JavaScript

Both

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
5 and
var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
6 contain all plugins in a single file. Include only one

Plugin dependencies

Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included before the plugin files). Consult our

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
9 to see which versions of jQuery are supported

Data attributes

You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first-class API and should be your first consideration when using a plugin

That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the document namespaced with

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
0. This looks like this

$(document).off('.data-api')

Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this

$(document).off('.alert.data-api')

Only one plugin per element via data attributes

Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, use a wrapping element

Programmatic API

We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon

$('.btn.danger').button('toggle').addClass('fat')

All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior)

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately

Each plugin also exposes its raw constructor on a

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
1 property.
$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
2. If you'd like to get a particular plugin instance, retrieve it directly from an element.
$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
3

Default settings

You can change the default settings for a plugin by modifying the plugin's

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
4 object

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false

No conflict

Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
5 on the plugin you wish to revert the value of

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality

Events

Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex.

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
6) is triggered at the start of an event, and its past participle form (ex.
$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
7) is triggered on the completion of an action

As of 3. 0. 0, all Bootstrap events are namespaced

All infinitive events provide

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
8 functionality. This provides the ability to stop the execution of an action before it starts

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})

Sanitizer

Tooltips and Popovers use our built-in sanitizer to sanitize options which accept HTML

The default

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
9 value is the following

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}

If you want to add new values to this default

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
9 you can do the following

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)

If you want to bypass our sanitizer because you prefer to use a dedicated library, for example DOMPurify, you should do the following

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})

Browsers without
$(document).off('.alert.data-api')
01

In case of browsers that don't support

$(document).off('.alert.data-api')
01, like Internet Explorer 8, the built-in sanitize function returns the HTML as is

If you want to perform sanitization in this case, please specify

$(document).off('.alert.data-api')
03 and use an external library like DOMPurify

Version numbers

The version of each of Bootstrap's jQuery plugins can be accessed via the

$(document).off('.alert.data-api')
04 property of the plugin's constructor. For example, for the tooltip plugin

$(document).off('.alert.data-api')
0

No special fallbacks when JavaScript is disabled

Bootstrap's plugins don't fall back particularly gracefully when JavaScript is disabled. If you care about the user experience in this case, use

$(document).off('.alert.data-api')
05to explain the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks

Thư viện của bên thứ ba

Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
5 and namespaced events, there may be compatibility problems that you need to fix on your own

About transitions

Đối với các hiệu ứng chuyển tiếp đơn giản, hãy bao gồm

$(document).off('.alert.data-api')
07 một lần cùng với các tệp JS khác. Nếu bạn đang sử dụng
var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
5 đã được biên dịch (hoặc được rút gọn), thì không cần thêm phần này—nó đã có sẵn rồi

Có gì bên trong

chuyển tiếp. js là trình trợ giúp cơ bản cho các sự kiện

$(document).off('.alert.data-api')
09 cũng như trình mô phỏng chuyển tiếp CSS. Nó được các plugin khác sử dụng để kiểm tra hỗ trợ chuyển tiếp CSS và để bắt các chuyển đổi bị treo

Vô hiệu hóa quá trình chuyển đổi

Chuyển đổi có thể bị vô hiệu hóa trên toàn cầu bằng cách sử dụng đoạn mã JavaScript sau, đoạn mã này phải xuất hiện sau khi tải xong

$(document).off('.alert.data-api')
07 (hoặc
var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
5 hoặc
var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
6, tùy từng trường hợp)

$(document).off('.alert.data-api')
1

Các phương thức được sắp xếp hợp lý, nhưng linh hoạt, lời nhắc hộp thoại với chức năng cần thiết tối thiểu và mặc định thông minh

Nhiều phương thức mở không được hỗ trợ

Đảm bảo không mở một phương thức trong khi một phương thức khác vẫn hiển thị. Hiển thị nhiều phương thức cùng một lúc yêu cầu mã tùy chỉnh

Vị trí đánh dấu phương thức

Luôn cố gắng đặt mã HTML của phương thức ở vị trí cấp cao nhất trong tài liệu của bạn để tránh các thành phần khác ảnh hưởng đến giao diện và/hoặc chức năng của phương thức

Do cách HTML5 xác định ngữ nghĩa của nó, thuộc tính HTML

$(document).off('.alert.data-api')
13 không có hiệu lực trong các phương thức Bootstrap. Để đạt được hiệu quả tương tự, hãy sử dụng một số JavaScript tùy chỉnh

$(document).off('.alert.data-api')
2

Examples

ví dụ tĩnh

A rendered modal with header, body, and set of actions in the footer

$(document).off('.alert.data-api')
3

Live demo

Toggle a modal via JavaScript by clicking the button below. It will slide down and fade in from the top of the page

Text in a modal

Duis mollis, est non commodo luctus, nisi erat porttitor ligula

Popover in a modal

This should trigger a popover on click

Tooltips in a modal

and should have tooltips on hover


Overflowing text to show scroll behavior

Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, tiền đình ở eros

Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor

Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla

Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, tiền đình ở eros

Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor

Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla

Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, tiền đình ở eros

Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor

Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla

$(document).off('.alert.data-api')
4

Make modals accessible

Be sure to add

$(document).off('.alert.data-api')
14 and
$(document).off('.alert.data-api')
15, referencing the modal title, to
$(document).off('.alert.data-api')
16, and
$(document).off('.alert.data-api')
17 to the
$(document).off('.alert.data-api')
18 itself

Additionally, you may give a description of your modal dialog with

$(document).off('.alert.data-api')
19 on
$(document).off('.alert.data-api')
16

Embedding YouTube videos

Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. See this helpful Stack Overflow post for more information

Optional sizes

Modals have two optional sizes, available via modifier classes to be placed on a

$(document).off('.alert.data-api')
18

$(document).off('.alert.data-api')
5

Remove animation

For modals that simply appear rather than fade in to view, remove the

$(document).off('.alert.data-api')
22 class from your modal markup

$(document).off('.alert.data-api')
6

Using the grid system

To take advantage of the Bootstrap grid system within a modal, just nest

$(document).off('.alert.data-api')
23s within the
$(document).off('.alert.data-api')
24 and then use the normal grid system classes

col-md-4 . col-md-offset-4

col-md-3 . col-md-offset-3

col-md-2 . col-md-offset-4

col-md-6 . col-md-offset-3

Level 1. . col-sm-9

Level 2. . col-xs-8 . col-sm-6

Level 2. . col-xs-4 . col-sm-6

$(document).off('.alert.data-api')
7

Have a bunch of buttons that all trigger the same modal, just with slightly different contents? Use

$(document).off('.alert.data-api')
25 and HTML
$(document).off('.alert.data-api')
26 attributes (possibly via jQuery) to vary the contents of the modal depending on which button was clicked. See the Modal Events docs for details on
$(document).off('.alert.data-api')
27,

Open modal for @mdo Open modal for @fat Open modal for @getbootstrap . more buttons

$(document).off('.alert.data-api')
8
$(document).off('.alert.data-api')
9

Usage

The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. Nó cũng thêm

$(document).off('.alert.data-api')
28 vào
$(document).off('.alert.data-api')
05 để ghi đè hành vi cuộn mặc định và tạo
$(document).off('.alert.data-api')
30 để cung cấp khu vực nhấp để loại bỏ các phương thức được hiển thị khi nhấp vào bên ngoài phương thức

Thông qua thuộc tính dữ liệu

Kích hoạt một phương thức mà không cần viết JavaScript. Đặt

$(document).off('.alert.data-api')
31 trên thành phần bộ điều khiển, chẳng hạn như nút, cùng với
$(document).off('.alert.data-api')
32 hoặc
$(document).off('.alert.data-api')
33 để nhắm mục tiêu một phương thức cụ thể để chuyển đổi

$('.btn.danger').button('toggle').addClass('fat')
0

Qua JavaScript

Gọi một phương thức có id

$(document).off('.alert.data-api')
34 bằng một dòng JavaScript

$('.btn.danger').button('toggle').addClass('fat')
1

Tùy chọn

Các tùy chọn có thể được chuyển qua thuộc tính dữ liệu hoặc JavaScript. Đối với các thuộc tính dữ liệu, hãy thêm tên tùy chọn vào

$(document).off('.alert.data-api')
35, như trong
$(document).off('.alert.data-api')
36

Nametypedefaultdescriptionbackdropboolean hoặc chuỗi

$(document).off('.alert.data-api')
37trueBao gồm phần tử phông nền phương thức. Ngoài ra, hãy chỉ định
$(document).off('.alert.data-api')
38 cho phông nền không đóng chế độ khi nhấp. keyboardbooleantrueĐóng phương thức khi nhấn phím thoátshowbooleantrueHiển thị phương thức khi được khởi tạo. điều khiển từ xa

Tùy chọn này không được dùng nữa kể từ v3. 3. 0 và đã bị xóa trong v4. Thay vào đó, chúng tôi khuyên bạn nên sử dụng khuôn mẫu phía máy khách hoặc khung liên kết dữ liệu hoặc gọi jQuery. tải cho mình

Nếu một URL từ xa được cung cấp, nội dung sẽ được tải một lần thông qua phương thức

$(document).off('.alert.data-api')
39 của jQuery và được đưa vào div
$(document).off('.alert.data-api')
40. Nếu bạn đang sử dụng data-api, bạn có thể sử dụng thuộc tính
$(document).off('.alert.data-api')
41 để chỉ định nguồn từ xa. Một ví dụ về điều này được hiển thị dưới đây

$('.btn.danger').button('toggle').addClass('fat')
2

phương pháp

$(document).off('.alert.data-api')
42

Kích hoạt nội dung của bạn dưới dạng phương thức. Chấp nhận một tùy chọn tùy chọn

$(document).off('.alert.data-api')
43

$('.btn.danger').button('toggle').addClass('fat')
3

$(document).off('.alert.data-api')
44

Bật/tắt chế độ theo cách thủ công. Trả về người gọi trước khi phương thức thực sự được hiển thị hoặc ẩn (i. e. trước khi sự kiện

$(document).off('.alert.data-api')
45 hoặc
$(document).off('.alert.data-api')
46 xảy ra)

$('.btn.danger').button('toggle').addClass('fat')
4

$(document).off('.alert.data-api')
47

Mở một phương thức theo cách thủ công. Trả về người gọi trước khi phương thức thực sự được hiển thị (i. e. trước khi sự kiện

$(document).off('.alert.data-api')
45 xảy ra)

$('.btn.danger').button('toggle').addClass('fat')
5

$(document).off('.alert.data-api')
49

Ẩn phương thức theo cách thủ công. Trả về người gọi trước khi phương thức thực sự bị ẩn (i. e. trước khi sự kiện

$(document).off('.alert.data-api')
46 xảy ra)

$('.btn.danger').button('toggle').addClass('fat')
6

$(document).off('.alert.data-api')
51

Điều chỉnh lại vị trí của phương thức để chống lại thanh cuộn trong trường hợp một thanh cuộn xuất hiện, điều này sẽ làm cho phương thức nhảy sang trái

Chỉ cần thiết khi chiều cao của phương thức thay đổi trong khi nó đang mở

$('.btn.danger').button('toggle').addClass('fat')
7

Events

Lớp phương thức của Bootstrap hiển thị một vài sự kiện để nối vào chức năng phương thức

Tất cả các sự kiện phương thức được kích hoạt tại chính phương thức đó (i. e. tại

$(document).off('.alert.data-api')
05)

Loại sự kiệnMô tảshow. bs. modal Sự kiện này kích hoạt ngay lập tức khi phương thức cá thể

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
6 được gọi. Nếu do nhấp chuột gây ra, phần tử được nhấp chuột có sẵn dưới dạng thuộc tính
$(document).off('.alert.data-api')
27 của sự kiện. cho xem. bs. modalSự kiện này được kích hoạt khi modal được hiển thị cho người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). Nếu do nhấp chuột gây ra, phần tử được nhấp chuột có sẵn dưới dạng thuộc tính
$(document).off('.alert.data-api')
27 của sự kiện. ẩn giấu. bs. modal Sự kiện này được kích hoạt ngay lập tức khi phương thức đối tượng
$(document).off('.alert.data-api')
56 được gọi. ẩn giấu. bs. modalSự kiện này được kích hoạt khi modal đã hoàn tất bị ẩn khỏi người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). nạp vào. bs. modal Sự kiện này được kích hoạt khi modal đã tải nội dung bằng tùy chọn
$(document).off('.alert.data-api')
57

$('.btn.danger').button('toggle').addClass('fat')
8

Examples

Thêm menu thả xuống vào hầu hết mọi thứ với plugin đơn giản này, bao gồm thanh điều hướng, tab và thuốc

Trong một thanh điều hướng

Trong viên thuốc

Usage

Thông qua thuộc tính dữ liệu hoặc JavaScript, plugin thả xuống chuyển đổi nội dung ẩn (menu thả xuống) bằng cách chuyển đổi lớp

$(document).off('.alert.data-api')
58 trên mục danh sách gốc

Trên thiết bị di động, việc mở danh sách thả xuống sẽ thêm

$(document).off('.alert.data-api')
59 làm khu vực nhấn để đóng menu thả xuống khi nhấn bên ngoài menu, một yêu cầu để được hỗ trợ iOS phù hợp. Điều này có nghĩa là việc chuyển từ menu thả xuống đang mở sang menu thả xuống khác yêu cầu một lần nhấn thêm trên thiết bị di động

Ghi chú. Thuộc tính

$(document).off('.alert.data-api')
60 được dựa vào để đóng menu thả xuống ở cấp ứng dụng, vì vậy, bạn nên luôn sử dụng thuộc tính này

Thông qua thuộc tính dữ liệu

Thêm

$(document).off('.alert.data-api')
60 vào một liên kết hoặc nút để chuyển đổi danh sách thả xuống

$('.btn.danger').button('toggle').addClass('fat')
9

Để giữ nguyên URL với các nút liên kết, hãy sử dụng thuộc tính

$(document).off('.alert.data-api')
62 thay vì
$(document).off('.alert.data-api')
63

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
0

Qua JavaScript

Gọi danh sách thả xuống qua JavaScript

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
1

$(document).off('.alert.data-api')
60 vẫn cần

Bất kể bạn gọi danh sách thả xuống của mình qua JavaScript hay thay vào đó sử dụng data-api, thì ____ 8_______60 luôn được yêu cầu phải có mặt trên phần tử kích hoạt của danh sách thả xuống

Tùy chọn

Không có

phương pháp

$(document).off('.alert.data-api')
66

Chuyển đổi menu thả xuống của một thanh điều hướng hoặc điều hướng theo thẻ nhất định

Events

Tất cả các sự kiện thả xuống được kích hoạt tại phần tử cha của

$(document).off('.alert.data-api')
67

Tất cả các sự kiện thả xuống đều có thuộc tính

$(document).off('.alert.data-api')
27, có giá trị là phần tử neo chuyển đổi

Loại sự kiệnMô tảshow. bs. dropdown Sự kiện này kích hoạt ngay lập tức khi phương thức thể hiện show được gọi. cho xem. bs. thả xuống Sự kiện này được kích hoạt khi danh sách thả xuống được hiển thị cho người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). ẩn giấu. bs. thả xuống Sự kiện này được kích hoạt ngay lập tức khi phương thức ẩn dụ được gọi. ẩn giấu. bs. thả xuốngSự kiện này được kích hoạt khi trình đơn thả xuống đã hoàn tất bị ẩn khỏi người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất)

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
2

Plugin ScrollSpy dùng để tự động cập nhật các mục tiêu điều hướng dựa trên vị trí cuộn. Cuộn khu vực bên dưới thanh điều hướng và xem thay đổi lớp đang hoạt động. The dropdown sub items will be highlighted as well

@mập mạp

Quảng cáo xà cạp keytar, brunch id art party dolorlabore. Pitchfork yr enim lo-fi trước khi bán hết veo. Xe đạp từ trang trại đến bàn Tumblr quyền bất cứ điều gì. Áo len hoạt hình keffiyeh carles. Gian hàng ảnh của velit seitan mcsweeney 3 sói trăng irure. Áo len Cosby lomo quần short jean, áo hoodie Williamsburg minim qui có thể bạn chưa từng nghe nói về chúng et cardigan quỹ tín thác dầu diesel sinh học culpa wes anderson thẩm mỹ. Nihil xăm lời buộc tội, tín dụng dầu diesel sinh học mỉa mai keffiyeh nghệ nhân ullamco hậu quả

@mdo

Veniam marfa ria ván trượt, adipisizing fugiat velit bộ râu chĩa ba. Freegan râu aliqua cupidatat mcsweeney's vero. Cupidatat bốn loko nisi, ea helvetica nulla carles. Hình xăm xe tải thực phẩm áo len cosby, vinyl của mcsweeney quis non freegan. Lo-fi wes anderson +1 quần áo. Carles phi thẩm mỹ bài tập quis gentrify. Brooklyn adipisizing bia thủ công vice keytar deserunt

một

Occaecat hàng hóa aliqua delectus. Fap bia thủ công ván trượt deserunt ea. Lomo xe đạp quyền adipisizing bánh mì, velit ea sunt next level locavore cà phê một nguồn gốc ở magna veniam. High life id vinyl, echo park dosequat quis aliquip bánh mì chĩa ba. Vero VHS được quảng cáo. Consectetur nisi DIY minim messenger bag. Cred ex in, delectus consectetur bền vững iphone pack

hai

Trong công viên tiếng vọng sự cố, chủ nhân xuất sắc của officia deserunt mcsweeney đã dọn sạch những con mèo sấm sét sapiente veniam. Ngoại trừ VHS elit, shoreditch cao cấp +1 bia thủ công làm bằng dầu diesel sinh học. Những người đi đường cà phê một nguồn gốc làm sạch bốn loko, cupidatat terry richardson master. Giả sử bạn có thể chưa nghe nói về họ bữa tiệc nghệ thuật fanny pack, quảng cáo áo khoác tạm thời nulla có hình xăm. Proident sói nesciunt sartorial keffiyeh eu banh mi bền vững. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt

số ba

Quảng cáo xà cạp keytar, brunch id art party dolorlabore. Pitchfork yr enim lo-fi trước khi bán hết veo. Xe đạp từ trang trại đến bàn Tumblr quyền bất cứ điều gì. Áo len hoạt hình keffiyeh carles. Gian hàng ảnh của velit seitan mcsweeney 3 sói trăng irure. Áo len Cosby lomo quần short jean, áo hoodie Williamsburg minim qui có thể bạn chưa từng nghe nói về chúng et cardigan quỹ tín thác dầu diesel sinh học culpa wes anderson thẩm mỹ. Nihil xăm lời buộc tội, tín dụng dầu diesel sinh học mỉa mai keffiyeh nghệ nhân ullamco hậu quả

Keytar twee blog, culpa messenger bag marfa anything delectus food truck. Sapiente synth id giả định. Locavore sed helvetica trớ trêu sáo rỗng, những con mèo sấm sét mà bạn có thể chưa từng nghe nói về chúng, hậu quả là áo hoodie lo-fi fap aliquip không chứa gluten. Labore elit placeat before they sold out, terry richardson bưa ăn nửa buổi cao cấp nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan thủ công bia seitan velit làm sẵn. VHS chambraylaboris tempor veniam. Anim mollit minim commodo ullamco thundercats

Yêu cầu mục tiêu ID có thể phân giải

Liên kết thanh điều hướng phải có các mục tiêu id có thể phân giải. Ví dụ, một

$(document).off('.alert.data-api')
69 phải tương ứng với một cái gì đó trong DOM như
$(document).off('.alert.data-api')
05

Các phần tử mục tiêu không phải ______8_______71 bị bỏ qua

Các phần tử đích không phải là

$(document).off('.alert.data-api')
71 theo jQuery sẽ bị bỏ qua và các mục điều hướng tương ứng của chúng sẽ không bao giờ được tô sáng

Yêu cầu định vị tương đối

Bất kể phương thức triển khai là gì, scrollspy yêu cầu sử dụng

$(document).off('.alert.data-api')
73 trên phần tử mà bạn đang theo dõi. In most cases this is the
$(document).off('.alert.data-api')
05. When scrollspying on elements other than the
$(document).off('.alert.data-api')
05, be sure to have a
$(document).off('.alert.data-api')
76 set and
$(document).off('.alert.data-api')
77 applied

Thông qua thuộc tính dữ liệu

To easily add scrollspy behavior to your topbar navigation, add

$(document).off('.alert.data-api')
78 to the element you want to spy on (most typically this would be the
$(document).off('.alert.data-api')
05). Then add the
$(document).off('.alert.data-api')
62 attribute with the ID or class of the parent element of any Bootstrap
$(document).off('.alert.data-api')
81 component

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
3
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
4

Qua JavaScript

After adding

$(document).off('.alert.data-api')
73 in your CSS, call the scrollspy via JavaScript

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
5

$(document).off('.alert.data-api')
83

When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
6

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to

$(document).off('.alert.data-api')
35, as in
$(document).off('.alert.data-api')
85

Nametypedefaultdescriptionoffsetnumber10Pixels to offset from top when calculating position of scroll

Event TypeDescriptionactivate. bs. scrollspyThis event fires whenever a new item becomes activated by the scrollspy

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
7

Example tabs

Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus. Nested tabs are not supported

Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui

Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park

Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr

Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan

Usage

Enable tabbable tabs via JavaScript (each tab needs to be activated individually)

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
8

You can activate individual tabs in several ways

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
9

Markup

You can activate a tab or pill navigation without writing any JavaScript by simply specifying

$(document).off('.alert.data-api')
86 or
$(document).off('.alert.data-api')
87 on an element. Adding the
$(document).off('.alert.data-api')
88 and
$(document).off('.alert.data-api')
89 classes to the tab
$(document).off('.alert.data-api')
90 will apply the Bootstrap , while adding the
$(document).off('.alert.data-api')
88 and
$(document).off('.alert.data-api')
92 classes will apply

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
0

hiệu ứng mờ dần

Để làm cho các tab mờ dần, hãy thêm

$(document).off('.alert.data-api')
22 vào mỗi
$(document).off('.alert.data-api')
94. Ngăn tab đầu tiên cũng phải có
$(document).off('.alert.data-api')
95 để hiển thị nội dung ban đầu

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
1

phương pháp

$(document).off('.alert.data-api')
96

Kích hoạt phần tử tab và vùng chứa nội dung. Tab phải có

$(document).off('.alert.data-api')
62 hoặc
$(document).off('.alert.data-api')
41 nhắm mục tiêu nút vùng chứa trong DOM. Trong các ví dụ trên, các tab là các
$(document).off('.alert.data-api')
05 với thuộc tính
$(document).off('.alert.data-api')
86

$('.btn.danger').button('toggle').addClass('fat')
01

Chọn tab đã cho và hiển thị nội dung được liên kết của nó. Any other tab that was previously selected becomes unselected and its associated content is hidden. Quay lại trình gọi trước khi ngăn tab thực sự được hiển thị (i. e. trước khi sự kiện

$('.btn.danger').button('toggle').addClass('fat')
02 xảy ra)

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
2

Events

Khi hiển thị một tab mới, các sự kiện sẽ kích hoạt theo thứ tự sau

  1. $('.btn.danger').button('toggle').addClass('fat')
    03 (trên tab đang hoạt động hiện tại)
  2. $('.btn.danger').button('toggle').addClass('fat')
    04 (trên tab sắp được hiển thị)
  3. $('.btn.danger').button('toggle').addClass('fat')
    05 (trên tab hoạt động trước đó, giống với tab đối với sự kiện
    $('.btn.danger').button('toggle').addClass('fat')
    03)
  4. $('.btn.danger').button('toggle').addClass('fat')
    02 (trên tab mới hoạt động vừa được hiển thị, giống như đối với sự kiện
    $('.btn.danger').button('toggle').addClass('fat')
    04)

Nếu không có tab nào đang hoạt động, thì các sự kiện

$('.btn.danger').button('toggle').addClass('fat')
03 và
$('.btn.danger').button('toggle').addClass('fat')
05 sẽ không được kích hoạt

Loại sự kiệnMô tảshow. bs. tabSự kiện này kích hoạt khi hiển thị tab, nhưng trước khi tab mới được hiển thị. Sử dụng

$('.btn.danger').button('toggle').addClass('fat')
11 và
$(document).off('.alert.data-api')
25 để nhắm mục tiêu tab đang hoạt động và tab đang hoạt động trước đó (nếu có) tương ứng. cho xem. bs. tabSự kiện này kích hoạt trên tab hiển thị sau khi một tab đã được hiển thị. Sử dụng
$('.btn.danger').button('toggle').addClass('fat')
11 và
$(document).off('.alert.data-api')
25 để nhắm mục tiêu tab đang hoạt động và tab đang hoạt động trước đó (nếu có) tương ứng. ẩn giấu. bs. tab Sự kiện này kích hoạt khi một tab mới được hiển thị (và do đó, tab đang hoạt động trước đó sẽ bị ẩn). Sử dụng
$('.btn.danger').button('toggle').addClass('fat')
11 và
$(document).off('.alert.data-api')
25 để nhắm mục tiêu tab đang hoạt động hiện tại và tab mới sắp hoạt động, tương ứng. ẩn giấu. bs. tabSự kiện này kích hoạt sau khi tab mới được hiển thị (và do đó, tab hoạt động trước đó bị ẩn). Sử dụng
$('.btn.danger').button('toggle').addClass('fat')
11 và
$(document).off('.alert.data-api')
25 để nhắm mục tiêu tab hoạt động trước đó và tab hoạt động mới tương ứng

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
3

Lấy cảm hứng từ jQuery xuất sắc. plugin say được viết bởi Jason Frame;

Chú giải công cụ có tiêu đề độ dài bằng 0 không bao giờ được hiển thị

Di chuột qua các liên kết bên dưới để xem chú giải công cụ

Quần bó cấp độ tiếp theo keffiyeh chưa nghe nói về chúng. Gian hàng chụp ảnh râu vải denim thô in chữ thuần chay túi messenger Stutttown. Seitan từ nông trại đến bàn ăn, mcsweeney's fixie bền vững quinoa Trang phục 8 bit của Mỹ terry richardson vinyl chambray. Beard studtown, cardigans bánh mì lomo thundercats. Đậu phụ dầu diesel sinh học williamsburg marfa, chambray thuần chay sạch của bốn loko mcsweeney. Một nghệ nhân thực sự mỉa mai, chủ ngân hàng từ trang trại đến bàn làm việc Austin freegan tín dụng denim thô cà phê một nguồn gốc lan truyền

chú giải công cụ tĩnh

Bốn tùy chọn có sẵn. căn trên, phải, dưới và trái

bốn hướng

Tooltip ở bên trái Tooltip ở trên Tooltip ở dưới Tooltip ở bên phải

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
4

Chức năng chọn tham gia

Vì lý do hiệu suất, apis dữ liệu Chú giải công cụ và Cửa sổ bật lên được chọn tham gia, nghĩa là bạn phải tự khởi tạo chúng

Một cách để khởi tạo tất cả chú giải công cụ trên một trang là chọn chúng theo thuộc tính

$('.btn.danger').button('toggle').addClass('fat')
19

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
5

Plugin chú giải công cụ tạo nội dung và đánh dấu theo yêu cầu và theo mặc định, đặt chú giải công cụ sau phần tử kích hoạt của chúng

Kích hoạt chú giải công cụ qua JavaScript

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
6

Markup

Đánh dấu bắt buộc cho chú giải công cụ chỉ là thuộc tính

$('.btn.danger').button('toggle').addClass('fat')
20 và
$('.btn.danger').button('toggle').addClass('fat')
21 trên phần tử HTML mà bạn muốn có chú giải công cụ. Đánh dấu được tạo của một chú giải công cụ khá đơn giản, mặc dù nó yêu cầu một vị trí (theo mặc định, được đặt thành
$('.btn.danger').button('toggle').addClass('fat')
22 bởi plugin)

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
7

Liên kết nhiều dòng

Đôi khi bạn muốn thêm một chú giải công cụ vào một siêu kết nối bao quanh nhiều dòng. Hành vi mặc định của plugin chú giải công cụ là căn giữa nó theo chiều ngang và chiều dọc. Thêm

$('.btn.danger').button('toggle').addClass('fat')
23 vào neo của bạn để tránh điều này

Chú giải công cụ trong nhóm nút, nhóm đầu vào và bảng yêu cầu cài đặt đặc biệt

Khi sử dụng chú giải công cụ trên các phần tử trong

$('.btn.danger').button('toggle').addClass('fat')
24 hoặc
$('.btn.danger').button('toggle').addClass('fat')
25 hoặc trên các phần tử liên quan đến bảng (
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05), bạn sẽ phải chỉ định tùy chọn
$('.btn.danger').button('toggle').addClass('fat')
32 (được ghi lại bên dưới) để tránh các tác dụng phụ không mong muốn

Đừng cố hiển thị chú giải công cụ trên các phần tử ẩn

Gọi

$('.btn.danger').button('toggle').addClass('fat')
33 khi phần tử đích là
$('.btn.danger').button('toggle').addClass('fat')
34 sẽ khiến chú giải công cụ được định vị không chính xác

Chú giải công cụ có thể truy cập cho người dùng bàn phím và công nghệ hỗ trợ

Đối với người dùng điều hướng bằng bàn phím và cụ thể là người dùng công nghệ hỗ trợ, bạn chỉ nên thêm chú giải công cụ vào các phần tử có thể tập trung vào bàn phím, chẳng hạn như liên kết, điều khiển biểu mẫu hoặc bất kỳ phần tử tùy ý nào có thuộc tính

$('.btn.danger').button('toggle').addClass('fat')
35

Chú giải công cụ về các phần tử bị vô hiệu hóa yêu cầu các phần tử bao bọc

Để thêm chú giải công cụ vào phần tử

$('.btn.danger').button('toggle').addClass('fat')
36 hoặc
$('.btn.danger').button('toggle').addClass('fat')
37, hãy đặt phần tử đó bên trong
$(document).off('.alert.data-api')
05 và thay vào đó áp dụng chú giải công cụ cho
$(document).off('.alert.data-api')
05 đó

Các tùy chọn có thể được chuyển qua thuộc tính dữ liệu hoặc JavaScript. Đối với các thuộc tính dữ liệu, hãy thêm tên tùy chọn vào

$(document).off('.alert.data-api')
35, như trong
$('.btn.danger').button('toggle').addClass('fat')
41

Lưu ý rằng vì lý do bảo mật, các tùy chọn

$('.btn.danger').button('toggle').addClass('fat')
42,
$(document).off('.alert.data-api')
03 và
$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
9 không thể được cung cấp bằng thuộc tính dữ liệu

NameTypeDefaultDescriptionanimationbooleantrueÁp dụng chuyển đổi làm mờ dần CSS cho tooltipcontainerstring. sai sự thật

Nối chú giải công cụ vào một phần tử cụ thể. Thí dụ.

$('.btn.danger').button('toggle').addClass('fat')
32. Tùy chọn này đặc biệt hữu ích vì nó cho phép bạn định vị chú giải công cụ trong luồng tài liệu gần phần tử kích hoạt - điều này sẽ ngăn chú giải công cụ trôi ra khỏi phần tử kích hoạt trong khi thay đổi kích thước cửa sổ

số chậm trễ. đối tượng0

Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type

Nếu một số được cung cấp, độ trễ được áp dụng cho cả ẩn/hiện

Cấu trúc đối tượng là.

$('.btn.danger').button('toggle').addClass('fat')
46

htmlbooleanfalseChèn HTML vào tooltip. Nếu sai, phương thức
$('.btn.danger').button('toggle').addClass('fat')
47 của jQuery sẽ được sử dụng để chèn nội dung vào DOM. Sử dụng văn bản nếu bạn lo lắng về các cuộc tấn công XSS. chuỗi vị trí. chức năng'top'

Cách định vị chú giải công cụ - trên cùng. đáy. bên trái. đúng. Tự động
Khi "tự động" được chỉ định, nó sẽ tự động định hướng lại chú giải công cụ. Ví dụ: nếu vị trí là "tự động sang trái", chú giải công cụ sẽ hiển thị ở bên trái khi có thể, nếu không nó sẽ hiển thị ở bên phải

Khi một hàm được sử dụng để xác định vị trí, nó được gọi với nút DOM chú giải công cụ làm đối số đầu tiên và nút DOM phần tử kích hoạt làm đối số thứ hai. Bối cảnh

$('.btn.danger').button('toggle').addClass('fat')
48 được đặt thành phiên bản chú giải công cụ

selectorstringfalseNếu bộ chọn được cung cấp, các đối tượng chú giải công cụ sẽ được ủy quyền cho các mục tiêu đã chỉ định. Trong thực tế, điều này cũng được sử dụng để áp dụng chú giải công cụ cho các phần tử DOM được thêm động (hỗ trợ ____9_______49). Xem cái này và một ví dụ thông tin. chuỗi mẫu_______9_______50

HTML cơ sở để sử dụng khi tạo chú giải công cụ

Chú giải công cụ của

$('.btn.danger').button('toggle').addClass('fat')
21 sẽ được đưa vào
$('.btn.danger').button('toggle').addClass('fat')
52

$('.btn.danger').button('toggle').addClass('fat')
53 sẽ trở thành mũi tên của chú giải công cụ

Phần tử bao ngoài cùng phải có lớp

$('.btn.danger').button('toggle').addClass('fat')
54

chuỗi tiêu đề. hàm số''

Giá trị tiêu đề mặc định nếu không có thuộc tính

$('.btn.danger').button('toggle').addClass('fat')
21

Nếu một chức năng được cung cấp, nó sẽ được gọi với tham chiếu

$('.btn.danger').button('toggle').addClass('fat')
48 được đặt thành phần tử mà chú giải công cụ được đính kèm

chuỗi kích hoạt'tiêu điểm di chuột'Cách chú giải công cụ được kích hoạt - nhấp. bay lượn. tiêu điểm. thủ công. Bạn có thể vượt qua nhiều trình kích hoạt; .
$('.btn.danger').button('toggle').addClass('fat')
57 không thể được kết hợp với bất kỳ trình kích hoạt nào khác. chuỗi khung nhìn. mục tiêu. chức năng { bộ chọn. 'cơ thể', phần đệm. 0 }

Giữ chú giải công cụ trong giới hạn của phần tử này. Thí dụ.

$('.btn.danger').button('toggle').addClass('fat')
58 hoặc
$('.btn.danger').button('toggle').addClass('fat')
59

Nếu một hàm được đưa ra, thì nó được gọi với nút DOM của phần tử kích hoạt làm đối số duy nhất của nó. Bối cảnh

$('.btn.danger').button('toggle').addClass('fat')
48 được đặt thành phiên bản chú giải công cụ

sanitizebooleantrueBật hoặc tắt khử trùng. Nếu kích hoạt các tùy chọn
$('.btn.danger').button('toggle').addClass('fat')
61,
$('.btn.danger').button('toggle').addClass('fat')
62 và
$('.btn.danger').button('toggle').addClass('fat')
63 sẽ được khử trùng. whiteListobjectObject chứa các thuộc tính và thẻ được phépsanitizeFnnull. functionnullỞ đây bạn có thể cung cấp chức năng khử trùng của riêng mình. Điều này có thể hữu ích nếu bạn muốn sử dụng thư viện chuyên dụng để thực hiện vệ sinh

Thuộc tính dữ liệu cho các chú giải công cụ riêng lẻ

Ngoài ra, các tùy chọn cho chú giải công cụ riêng lẻ có thể được chỉ định thông qua việc sử dụng các thuộc tính dữ liệu, như đã giải thích ở trên

$('.btn.danger').button('toggle').addClass('fat')
64

Đính kèm trình xử lý chú giải công cụ vào bộ sưu tập phần tử

$('.btn.danger').button('toggle').addClass('fat')
65

Tiết lộ chú giải công cụ của một phần tử. Trả về trình gọi trước khi chú giải công cụ thực sự được hiển thị (i. e. trước khi sự kiện

$('.btn.danger').button('toggle').addClass('fat')
66 xảy ra). Đây được coi là kích hoạt "thủ công" của chú giải công cụ. Chú giải công cụ có tiêu đề độ dài bằng 0 không bao giờ được hiển thị

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
8

$('.btn.danger').button('toggle').addClass('fat')
67

Ẩn chú giải công cụ của một phần tử. Trả về trình gọi trước khi chú giải công cụ thực sự bị ẩn (i. e. trước khi sự kiện

$('.btn.danger').button('toggle').addClass('fat')
68 xảy ra). Đây được coi là kích hoạt "thủ công" của chú giải công cụ

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
9

$('.btn.danger').button('toggle').addClass('fat')
69

Chuyển đổi chú giải công cụ của một phần tử. Trả về trình gọi trước khi chú giải công cụ thực sự được hiển thị hoặc ẩn (i. e. trước khi sự kiện

$('.btn.danger').button('toggle').addClass('fat')
66 hoặc
$('.btn.danger').button('toggle').addClass('fat')
68 xảy ra). Đây được coi là kích hoạt "thủ công" của chú giải công cụ

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
0

$('.btn.danger').button('toggle').addClass('fat')
72

Ẩn và phá hủy tooltip của một phần tử. Chú giải công cụ sử dụng ủy quyền (được tạo bằng cách sử dụng ) không thể bị hủy riêng lẻ trên các phần tử kích hoạt hậu duệ

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
1

Loại sự kiệnMô tảshow. bs. tooltip Sự kiện này kích hoạt ngay lập tức khi phương thức đối tượng

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
6 được gọi. cho xem. bs. tooltip Sự kiện này được kích hoạt khi tooltip được hiển thị cho người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). ẩn giấu. bs. tooltip Sự kiện này được kích hoạt ngay lập tức khi phương thức đối tượng
$(document).off('.alert.data-api')
56 được gọi. ẩn giấu. bs. tooltip Sự kiện này được kích hoạt khi tooltip đã được ẩn khỏi người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). chèn vào. bs. tooltip Sự kiện này được kích hoạt sau sự kiện
$('.btn.danger').button('toggle').addClass('fat')
76 khi mẫu tooltip đã được thêm vào DOM

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
2

Thêm các lớp phủ nội dung nhỏ, chẳng hạn như trên iPad, vào bất kỳ thành phần nào để chứa thông tin thứ cấp

Cửa sổ bật lên có cả tiêu đề và nội dung đều có độ dài bằng 0 sẽ không bao giờ được hiển thị

Phụ thuộc plugin

Cửa sổ bật lên yêu cầu phải được đưa vào phiên bản Bootstrap của bạn

Chức năng chọn tham gia

Vì lý do hiệu suất, apis dữ liệu Chú giải công cụ và Cửa sổ bật lên được chọn tham gia, nghĩa là bạn phải tự khởi tạo chúng

Một cách để khởi tạo tất cả các cửa sổ bật lên trên một trang là chọn chúng theo thuộc tính

$('.btn.danger').button('toggle').addClass('fat')
19 của chúng

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
3

Cửa sổ bật lên trong nhóm nút, nhóm đầu vào và bảng yêu cầu cài đặt đặc biệt

Khi sử dụng cửa sổ bật lên trên các phần tử trong

$('.btn.danger').button('toggle').addClass('fat')
24 hoặc
$('.btn.danger').button('toggle').addClass('fat')
25 hoặc trên các phần tử liên quan đến bảng (
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05,
$(document).off('.alert.data-api')
05), bạn sẽ phải chỉ định tùy chọn
$('.btn.danger').button('toggle').addClass('fat')
32 (được ghi lại bên dưới) để tránh các tác dụng phụ không mong muốn

Đừng cố hiển thị cửa sổ bật lên trên các phần tử ẩn

Gọi

$('.btn.danger').button('toggle').addClass('fat')
87 khi phần tử đích là
$('.btn.danger').button('toggle').addClass('fat')
34 sẽ khiến cửa sổ bật lên bị đặt sai vị trí

Cửa sổ bật lên trên các phần tử bị vô hiệu hóa yêu cầu các phần tử bao bọc

Để thêm cửa sổ bật lên vào phần tử

$('.btn.danger').button('toggle').addClass('fat')
36 hoặc
$('.btn.danger').button('toggle').addClass('fat')
37, hãy đặt phần tử bên trong
$(document).off('.alert.data-api')
05 và thay vào đó áp dụng cửa sổ bật lên cho
$(document).off('.alert.data-api')
05 đó

Liên kết nhiều dòng

Đôi khi bạn muốn thêm cửa sổ bật lên vào siêu kết nối bao quanh nhiều dòng. Hành vi mặc định của plugin popover là căn giữa nó theo chiều ngang và chiều dọc. Thêm

$('.btn.danger').button('toggle').addClass('fat')
23 vào neo của bạn để tránh điều này

Examples

Cửa sổ bật lên tĩnh

Bốn tùy chọn có sẵn. căn trên, phải, dưới và trái

cửa sổ bật lên

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum

Cửa sổ bật lên bên phải

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum

đáy cửa sổ bật lên

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum

Cửa sổ bật lên bên trái

Sed posuere consectetur est at lobortis. Aenean eu leo ​​quam. Pellentesque ornare sem lacinia quam venenatis vestibulum

Live demo

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
4

bốn hướng

Popover ở bên phải Popover ở trên Popover ở dưới Popover ở bên trái

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
5

Bỏ qua lần nhấp tiếp theo

Sử dụng trình kích hoạt

$('.btn.danger').button('toggle').addClass('fat')
94 để loại bỏ cửa sổ bật lên trong lần nhấp tiếp theo mà người dùng thực hiện

Yêu cầu đánh dấu cụ thể để loại bỏ khi nhấp vào lần nhấp tiếp theo

Đối với hành vi đa trình duyệt và đa nền tảng thích hợp, bạn phải sử dụng thẻ

$(document).off('.alert.data-api')
05, không phải thẻ
$(document).off('.alert.data-api')
05 và bạn cũng phải bao gồm các thuộc tính
$('.btn.danger').button('toggle').addClass('fat')
97 và
$('.btn.danger').button('toggle').addClass('fat')
98

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
6

Usage

Kích hoạt cửa sổ bật lên qua JavaScript

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
7

Tùy chọn

Các tùy chọn có thể được chuyển qua thuộc tính dữ liệu hoặc JavaScript. Đối với các thuộc tính dữ liệu, hãy thêm tên tùy chọn vào

$(document).off('.alert.data-api')
35, như trong
$('.btn.danger').button('toggle').addClass('fat')
41

Lưu ý rằng vì lý do bảo mật, các tùy chọn

$('.btn.danger').button('toggle').addClass('fat')
42,
$(document).off('.alert.data-api')
03 và
$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
9 không thể được cung cấp bằng thuộc tính dữ liệu

NameTypeDefaultDescriptionanimationbooleantrueÁp dụng chuyển đổi mờ dần CSS cho chuỗi popovercontainer. sai sự thật

Nối popover vào một phần tử cụ thể. Thí dụ.

$('.btn.danger').button('toggle').addClass('fat')
32. Tùy chọn này đặc biệt hữu ích vì nó cho phép bạn định vị cửa sổ bật lên trong luồng tài liệu gần phần tử kích hoạt - điều này sẽ ngăn cửa sổ bật lên trôi ra khỏi phần tử kích hoạt trong khi thay đổi kích thước cửa sổ

chuỗi nội dung. hàm số''

Giá trị nội dung mặc định nếu không có thuộc tính

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
05

Nếu một chức năng được đưa ra, nó sẽ được gọi với tham chiếu

$('.btn.danger').button('toggle').addClass('fat')
48 của nó được đặt thành phần tử mà cửa sổ bật lên được gắn vào

số chậm trễ. đối tượng0

Độ trễ hiển thị và ẩn cửa sổ bật lên (ms) - không áp dụng cho loại trình kích hoạt thủ công

Nếu một số được cung cấp, độ trễ được áp dụng cho cả ẩn/hiện

Cấu trúc đối tượng là.

$('.btn.danger').button('toggle').addClass('fat')
46

htmlbooleanfalseChèn HTML vào cửa sổ bật lên. Nếu sai, phương thức
$('.btn.danger').button('toggle').addClass('fat')
47 của jQuery sẽ được sử dụng để chèn nội dung vào DOM. Sử dụng văn bản nếu bạn lo lắng về các cuộc tấn công XSS. chuỗi vị trí. chức năng'đúng'

Cách định vị cửa sổ bật lên - trên cùng. đáy. bên trái. đúng. Tự động
Khi "tự động" được chỉ định, nó sẽ tự động định hướng lại cửa sổ bật lên. Ví dụ: nếu vị trí là "tự động sang trái", cửa sổ bật lên sẽ hiển thị ở bên trái khi có thể, nếu không nó sẽ hiển thị ở bên phải

Khi một hàm được sử dụng để xác định vị trí, nó được gọi với nút DOM cửa sổ bật lên làm đối số đầu tiên và nút DOM phần tử kích hoạt làm đối số thứ hai. Bối cảnh

$('.btn.danger').button('toggle').addClass('fat')
48 được đặt thành phiên bản popover

selectorstringfalseNếu một bộ chọn được cung cấp, các đối tượng bật lên sẽ được ủy quyền cho các mục tiêu đã chỉ định. Trong thực tế, điều này được sử dụng để cho phép nội dung HTML động có thêm cửa sổ bật lên. Xem cái này và một ví dụ thông tin. chuỗi mẫu_______10_______10

HTML cơ sở để sử dụng khi tạo cửa sổ bật lên

Cửa sổ bật lên của

$('.btn.danger').button('toggle').addClass('fat')
21 sẽ được tiêm vào
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
12

Cửa sổ bật lên của

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
13 sẽ được tiêm vào
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
14

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
15 sẽ trở thành mũi tên của popover

Phần tử bao ngoài cùng phải có lớp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
16

chuỗi tiêu đề. hàm số''

Giá trị tiêu đề mặc định nếu không có thuộc tính

$('.btn.danger').button('toggle').addClass('fat')
21

Nếu một chức năng được đưa ra, nó sẽ được gọi với tham chiếu

$('.btn.danger').button('toggle').addClass('fat')
48 của nó được đặt thành phần tử mà cửa sổ bật lên được gắn vào

chuỗi kích hoạt'click'Cách kích hoạt cửa sổ bật lên - nhấp chuột. bay lượn. tiêu điểm. thủ công. Bạn có thể vượt qua nhiều trình kích hoạt; .
$('.btn.danger').button('toggle').addClass('fat')
57 không thể được kết hợp với bất kỳ trình kích hoạt nào khác. chuỗi khung nhìn. mục tiêu. chức năng { bộ chọn. 'cơ thể', phần đệm. 0 }

Giữ cửa sổ bật lên trong giới hạn của phần tử này. Thí dụ.

$('.btn.danger').button('toggle').addClass('fat')
58 hoặc
$('.btn.danger').button('toggle').addClass('fat')
59

Nếu một hàm được đưa ra, thì nó được gọi với nút DOM của phần tử kích hoạt làm đối số duy nhất của nó. Bối cảnh

$('.btn.danger').button('toggle').addClass('fat')
48 được đặt thành phiên bản popover

sanitizebooleantrueBật hoặc tắt khử trùng. Nếu kích hoạt các tùy chọn
$('.btn.danger').button('toggle').addClass('fat')
61,
$('.btn.danger').button('toggle').addClass('fat')
62 và
$('.btn.danger').button('toggle').addClass('fat')
63 sẽ được khử trùng. whiteListobjectObject chứa các thuộc tính và thẻ được phépsanitizeFnnull. functionnullỞ đây bạn có thể cung cấp chức năng khử trùng của riêng mình. Điều này có thể hữu ích nếu bạn muốn sử dụng thư viện chuyên dụng để thực hiện vệ sinh

Thuộc tính dữ liệu cho các cửa sổ bật lên riêng lẻ

Ngoài ra, các tùy chọn cho các cửa sổ bật lên riêng lẻ có thể được chỉ định thông qua việc sử dụng các thuộc tính dữ liệu, như đã giải thích ở trên

phương pháp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
26

Khởi tạo cửa sổ bật lên cho một bộ sưu tập phần tử

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
27

Hiển thị cửa sổ bật lên của một phần tử. Trả về người gọi trước khi cửa sổ bật lên thực sự được hiển thị (i. e. trước khi sự kiện

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
28 xảy ra). Đây được coi là cách kích hoạt popover "thủ công". Cửa sổ bật lên có cả tiêu đề và nội dung đều có độ dài bằng 0 sẽ không bao giờ được hiển thị

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
8

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
29

Ẩn popover của một phần tử. Trả về người gọi trước khi cửa sổ bật lên thực sự bị ẩn (i. e. trước khi sự kiện

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
30 xảy ra). Đây được coi là cách kích hoạt popover "thủ công"

var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
$.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
9

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
31

Chuyển đổi cửa sổ bật lên của một phần tử. Trả về người gọi trước khi cửa sổ bật lên thực sự được hiển thị hoặc ẩn (i. e. trước khi sự kiện

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
28 hoặc
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
30 xảy ra). Đây được coi là cách kích hoạt popover "thủ công"

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
0

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
34

Ẩn và phá hủy cửa sổ bật lên của một phần tử. Cửa sổ bật lên sử dụng ủy quyền (được tạo bằng cách sử dụng ) không thể bị hủy riêng lẻ trên các phần tử kích hoạt con cháu

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
1

Events

Loại sự kiệnMô tảshow. bs. popover Sự kiện này kích hoạt ngay lập tức khi phương thức đối tượng

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
6 được gọi. cho xem. bs. cửa sổ bật lên Sự kiện này được kích hoạt khi cửa sổ bật lên hiển thị với người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). ẩn giấu. bs. popover Sự kiện này được kích hoạt ngay lập tức khi phương thức cá thể
$(document).off('.alert.data-api')
56 được gọi. ẩn giấu. bs. cửa sổ bật lên Sự kiện này được kích hoạt khi cửa sổ bật lên đã hoàn tất bị ẩn khỏi người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). chèn vào. bs. cửa sổ bật lên Sự kiện này được kích hoạt sau sự kiện
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
38 khi mẫu cửa sổ bật lên đã được thêm vào DOM

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
2

Example alerts

Thêm chức năng loại bỏ tất cả các thông báo cảnh báo bằng plugin này

Khi sử dụng nút

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
39, nút này phải là nút con đầu tiên của nút
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
40 và không có nội dung văn bản nào có thể xuất hiện trước nó trong phần đánh dấu

× Nước sốt bơ thần thánh. Tốt nhất hãy tự kiểm tra lại đi, trông bạn không được ổn cho lắm

×

Oh snap. Bạn gặp lỗi

Thay đổi cái này và cái kia và thử lại. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum

Thực hiện hành động này Hoặc làm điều này

Usage

Chỉ cần thêm

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
41 vào nút đóng của bạn để tự động đưa ra chức năng đóng cảnh báo. Đóng một cảnh báo sẽ xóa nó khỏi DOM

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
3

Để các cảnh báo của bạn sử dụng hoạt ảnh khi đóng cửa, hãy đảm bảo rằng chúng đã được áp dụng các lớp

$(document).off('.alert.data-api')
22 và
$(document).off('.alert.data-api')
95

phương pháp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
44

Tạo cảnh báo lắng nghe các sự kiện nhấp chuột trên các phần tử con cháu có thuộc tính

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
41. (Không cần thiết khi sử dụng tính năng khởi tạo tự động của data-api. )

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
46

Đóng cảnh báo bằng cách xóa nó khỏi DOM. Nếu các lớp

$(document).off('.alert.data-api')
22 và
$(document).off('.alert.data-api')
95 xuất hiện trên phần tử, cảnh báo sẽ mờ dần trước khi nó bị xóa

Events

Plugin cảnh báo Bootstrap hiển thị một vài sự kiện để nối vào chức năng cảnh báo

Loại sự kiệnMô tảĐóng. bs. alertSự kiện này kích hoạt ngay lập tức khi phương thức đối tượng

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
49 được gọi. đóng cửa. bs. alertSự kiện này được kích hoạt khi cảnh báo đã bị đóng (sẽ đợi quá trình chuyển đổi CSS hoàn tất)

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
4

Làm nhiều hơn với các nút. Trạng thái nút điều khiển hoặc tạo nhóm nút cho nhiều thành phần hơn như thanh công cụ

nhà nước

Thêm

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
50 để sử dụng trạng thái tải trên một nút

Tính năng này không được dùng nữa kể từ v3. 3. 5 và đã bị xóa trong v4

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
5

chuyển đổi đơn

Thêm

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
51 để kích hoạt chuyển đổi trên một nút duy nhất

Các nút được chuyển đổi trước cần có
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
52 và
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
53

Đối với các nút được chuyển đổi trước, bạn phải thêm lớp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
52 và thuộc tính
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
53 vào chính
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
56

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
6

Hộp kiểm / Radio

Thêm

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
57 vào hộp kiểm chứa
$('.btn.danger').button('toggle').addClass('fat')
24 hoặc đầu vào radio để cho phép chuyển đổi theo kiểu tương ứng của chúng

Các tùy chọn được chọn trước cần
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
52

Đối với các tùy chọn được chọn trước, bạn phải tự thêm lớp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
52 vào đầu vào của
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
61

Trạng thái kiểm tra trực quan chỉ được cập nhật khi nhấp

Nếu trạng thái đã chọn của nút hộp kiểm được cập nhật mà không kích hoạt sự kiện

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
62 trên nút (e. g. thông qua
$(document).off('.alert.data-api')
05 hoặc thông qua việc đặt thuộc tính
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
64 của đầu vào), bạn sẽ cần phải tự mình chuyển đổi lớp
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
52 trên đầu vào của
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
61

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
7_______21_______8

phương pháp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
67

Chuyển đổi trạng thái đẩy. Cung cấp cho nút xuất hiện rằng nó đã được kích hoạt

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
68

Đặt lại trạng thái nút - hoán đổi văn bản thành văn bản gốc. Phương thức này không đồng bộ và trả về trước khi quá trình đặt lại thực sự hoàn tất

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
69

Hoán đổi văn bản thành bất kỳ trạng thái văn bản được xác định dữ liệu nào

$('#myModal').on('show.bs.modal', function (e) {
  if (!data) return e.preventDefault() // stops modal from being shown
})
9

Plugin linh hoạt sử dụng một số lớp để dễ dàng chuyển đổi hành vi

Phụ thuộc plugin

Thu gọn yêu cầu phải được đưa vào phiên bản Bootstrap của bạn

Thí dụ

Nhấp vào các nút bên dưới để hiển thị và ẩn phần tử khác thông qua thay đổi lớp

  • $('#myModal').modal()                      // initialized with defaults
    $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
    $('#myModal').modal('show')                // initializes and invokes show immediately
    70 ẩn nội dung
  • $('#myModal').modal()                      // initialized with defaults
    $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
    $('#myModal').modal('show')                // initializes and invokes show immediately
    71 được áp dụng trong quá trình chuyển đổi
  • $('#myModal').modal()                      // initialized with defaults
    $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
    $('#myModal').modal('show')                // initializes and invokes show immediately
    72 hiển thị nội dung

Bạn có thể sử dụng liên kết có thuộc tính

$(document).off('.alert.data-api')
41 hoặc nút có thuộc tính
$(document).off('.alert.data-api')
62. In both cases, the
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
75 is required

Nút có mục tiêu dữ liệu

Anim pariatur cliche reprehenderit, enim eiusmod cuộc sống cao accusamus terry richardson quảng cáo mực. Nihil anim keffiyeh helvetica, bia thủ cônglabore wes anderson cred nesciunt sapiente ea proident

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
0

ví dụ đàn accordion

Mở rộng hành vi thu gọn mặc định để tạo đàn accordion với thành phần bảng điều khiển

Anim pariatur cliche reprehenderit, enim eiusmod cuộc sống cao accusamus terry richardson quảng cáo mực. 3 sói mặt trăng chính thức cấp tính, không cupidatat trượt ván dolor brunch. Xe tải thực phẩm quinoa nesciuntlaborum eiusmod. Bữa nửa buổi 3 sói mặt trăng tạm thời, sunt aliqua đặt một con chim trên đó mực cà phê một nguồn gốc nulla giả định shoreditch et. Nihil anim keffiyeh helvetica, bia thủ cônglabore wes anderson cred nesciunt sapiente ea proident. Quảng cáo người ăn chay ngoại trừ người bán thịt phó lomo. Xà cạp occaecat bia thủ công từ trang trại đến bàn ăn, tổng hợp thẩm mỹ denim thô chưa từng được biết đến mà bạn có thể chưa từng nghe nói về chúng accusamuslabore bền vững VHS

Anim pariatur cliche reprehenderit, enim eiusmod cuộc sống cao accusamus terry richardson quảng cáo mực. 3 sói mặt trăng chính thức cấp tính, không cupidatat trượt ván dolor brunch. Xe tải thực phẩm quinoa nesciuntlaborum eiusmod. Bữa nửa buổi 3 sói mặt trăng tạm thời, sunt aliqua đặt một con chim trên đó mực cà phê một nguồn gốc nulla giả định shoreditch et. Nihil anim keffiyeh helvetica, bia thủ cônglabore wes anderson cred nesciunt sapiente ea proident. Quảng cáo người ăn chay ngoại trừ người bán thịt phó lomo. Xà cạp occaecat bia thủ công từ trang trại đến bàn ăn, tổng hợp thẩm mỹ denim thô chưa từng được biết đến mà bạn có thể chưa từng nghe nói về chúng accusamuslabore bền vững VHS

Anim pariatur cliche reprehenderit, enim eiusmod cuộc sống cao accusamus terry richardson quảng cáo mực. 3 sói mặt trăng chính thức cấp tính, không cupidatat trượt ván dolor brunch. Xe tải thực phẩm quinoa nesciuntlaborum eiusmod. Bữa nửa buổi 3 sói mặt trăng tạm thời, sunt aliqua đặt một con chim trên đó mực cà phê một nguồn gốc nulla giả định shoreditch et. Nihil anim keffiyeh helvetica, bia thủ cônglabore wes anderson cred nesciunt sapiente ea proident. Quảng cáo người ăn chay ngoại trừ người bán thịt phó lomo. Xà cạp occaecat bia thủ công từ trang trại đến bàn ăn, tổng hợp thẩm mỹ denim thô chưa từng được biết đến mà bạn có thể chưa từng nghe nói về chúng accusamuslabore bền vững VHS

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
1

Cũng có thể hoán đổi

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
76s với
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
77s

  • Bootply
  • Một itmus ac facilin
  • tình yêu thứ hai

Làm cho các điều khiển mở rộng/thu gọn có thể truy cập được

Đảm bảo thêm

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
78 vào thành phần điều khiển. Thuộc tính này xác định rõ ràng trạng thái hiện tại của phần tử có thể thu gọn đối với trình đọc màn hình và các công nghệ hỗ trợ tương tự. Nếu phần tử có thể thu gọn được đóng theo mặc định, thì phần tử đó phải có giá trị là
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
79. Nếu bạn đã đặt phần tử có thể thu gọn thành mở theo mặc định bằng cách sử dụng lớp
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
80, thay vào đó, hãy đặt
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
81 trên điều khiển. Plugin sẽ tự động chuyển đổi thuộc tính này dựa trên việc phần tử có thể thu gọn đã được mở hay đóng

Ngoài ra, nếu phần tử điều khiển của bạn đang nhắm mục tiêu một phần tử có thể thu gọn duy nhất – tôi. e. thuộc tính

$(document).off('.alert.data-api')
62 đang trỏ đến bộ chọn
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
83 – bạn có thể thêm thuộc tính bổ sung
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
84 vào phần tử điều khiển, chứa ____10_______83 của phần tử có thể thu gọn. Trình đọc màn hình hiện đại và các công nghệ hỗ trợ tương tự sử dụng thuộc tính này để cung cấp cho người dùng các phím tắt bổ sung để điều hướng trực tiếp đến chính phần tử có thể thu gọn

Usage

Plugin thu gọn sử dụng một vài lớp để xử lý việc nâng vật nặng

  • $('#myModal').modal()                      // initialized with defaults
    $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
    $('#myModal').modal('show')                // initializes and invokes show immediately
    70 ẩn nội dung
  • $('#myModal').modal()                      // initialized with defaults
    $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
    $('#myModal').modal('show')                // initializes and invokes show immediately
    72 hiển thị nội dung
  • $('#myModal').modal()                      // initialized with defaults
    $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
    $('#myModal').modal('show')                // initializes and invokes show immediately
    71 được thêm vào khi quá trình chuyển đổi bắt đầu và bị xóa khi quá trình chuyển đổi kết thúc

Các lớp này có thể được tìm thấy trong

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
89

Thông qua thuộc tính dữ liệu

Chỉ cần thêm

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
75 và
$(document).off('.alert.data-api')
62 vào phần tử để tự động gán quyền kiểm soát phần tử có thể thu gọn. Thuộc tính
$(document).off('.alert.data-api')
62 chấp nhận bộ chọn CSS để áp dụng thu gọn cho. Đảm bảo thêm lớp
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
93 vào phần tử có thể thu gọn. Nếu bạn muốn nó mở mặc định, hãy thêm lớp bổ sung
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
80

Để thêm tính năng quản lý nhóm giống như đàn accordion vào điều khiển có thể thu gọn, hãy thêm thuộc tính dữ liệu

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
95. Tham khảo bản demo để thấy điều này trong thực tế

Qua JavaScript

Kích hoạt thủ công với

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
2

Tùy chọn

Các tùy chọn có thể được chuyển qua thuộc tính dữ liệu hoặc JavaScript. Đối với các thuộc tính dữ liệu, hãy thêm tên tùy chọn vào

$(document).off('.alert.data-api')
35, như trong
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
97

NametypedefaultdescriptionparentselectorfalseNếu một bộ chọn được cung cấp, thì tất cả các phần tử có thể thu gọn bên dưới cấp độ gốc được chỉ định sẽ bị đóng khi mục có thể thu gọn này được hiển thị. (tương tự như hành vi của đàn accordion truyền thống - điều này phụ thuộc vào lớp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
98)togglebooleantrueBật/tắt phần tử có thể thu gọn khi gọi

phương pháp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
99

Kích hoạt nội dung của bạn dưới dạng phần tử có thể thu gọn. Chấp nhận một tùy chọn tùy chọn

$(document).off('.alert.data-api')
43

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
3

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
01

Chuyển một phần tử có thể thu gọn sang hiển thị hoặc ẩn. Trả về trình gọi trước khi phần tử có thể thu gọn thực sự được hiển thị hoặc ẩn (i. e. trước khi sự kiện

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
02 hoặc
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
03 xảy ra)

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
04

Hiển thị một phần tử có thể thu gọn. Trả về trình gọi trước khi phần tử có thể thu gọn thực sự được hiển thị (i. e. trước khi sự kiện

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
02 xảy ra)

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
06

Ẩn phần tử có thể thu gọn. Trả về trình gọi trước khi phần tử có thể thu gọn thực sự bị ẩn (i. e. trước khi sự kiện

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
03 xảy ra)

Events

Lớp thu gọn Bootstrap hiển thị một vài sự kiện để nối vào chức năng thu gọn

Loại sự kiệnMô tảshow. bs. sụp đổSự kiện này kích hoạt ngay lập tức khi phương thức cá thể

$('#yourTooltip').tooltip({
  sanitizeFn: function (content) {
    return DOMPurify.sanitize(content)
  }
})
6 được gọi. cho xem. bs. sụp đổSự kiện này được kích hoạt khi phần tử thu gọn đã được hiển thị cho người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất). ẩn giấu. bs. sự sụp đổ Sự kiện này được kích hoạt ngay lập tức khi phương thức
$(document).off('.alert.data-api')
56 được gọi. ẩn giấu. bs. sụp đổSự kiện này được kích hoạt khi phần tử thu gọn đã bị ẩn khỏi người dùng (sẽ đợi quá trình chuyển đổi CSS hoàn tất)

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
4

Thành phần trình chiếu để quay vòng qua các phần tử, chẳng hạn như băng chuyền. Băng chuyền lồng nhau không được hỗ trợ

Examples

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
5

Vấn đề trợ năng

Thành phần băng chuyền thường không tuân thủ các tiêu chuẩn trợ năng. Nếu bạn cần phải tuân thủ, vui lòng xem xét các tùy chọn khác để trình bày nội dung của bạn

Hoạt hình chuyển tiếp không được hỗ trợ trong Internet Explorer 8 & 9

Bootstrap chỉ sử dụng CSS3 cho hoạt ảnh của nó, nhưng Internet Explorer 8 & 9 không hỗ trợ các thuộc tính CSS cần thiết. Do đó, không có hoạt ảnh chuyển tiếp slide khi sử dụng các trình duyệt này. Chúng tôi đã cố ý quyết định không bao gồm các dự phòng dựa trên jQuery cho quá trình chuyển đổi

Yêu cầu yếu tố hoạt động ban đầu

Lớp

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
52 cần được thêm vào một trong các trang chiếu. Nếu không, băng chuyền sẽ không hiển thị

Biểu tượng Glyphicon không cần thiết

Các lớp

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
11 và
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
12 không nhất thiết cần thiết cho các điều khiển. Bootstrap cung cấp
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
13 và
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
14 dưới dạng các lựa chọn thay thế unicode đơn giản

chú thích tùy chọn

Thêm chú thích vào trang chiếu của bạn một cách dễ dàng với phần tử

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
15 trong bất kỳ
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
16 nào. Đặt bất kỳ HTML tùy chọn nào trong đó và nó sẽ tự động được căn chỉnh và định dạng

First slide image

Nhãn trượt đầu tiên

Nulla vitae elit libero, pharetra augue mollis interdum

Second slide image

Second slide label

Lorem ipsum dolor sit amet, consectetur adipiscing elit

Third slide image

Nhãn trượt thứ ba

Praesent commodo cursus magna, vel scelerisque nisl consectetur

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
6

Usage

Nhiều băng chuyền

Băng chuyền yêu cầu sử dụng một

$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
83 trên thùng chứa ngoài cùng (_______15_______18) để điều khiển băng chuyền hoạt động bình thường. Khi thêm nhiều băng chuyền hoặc khi thay đổi
$('#myModal').modal()                      // initialized with defaults
$('#myModal').modal({ keyboard: false })   // initialized with no keyboard
$('#myModal').modal('show')                // initializes and invokes show immediately
83 của băng chuyền, hãy đảm bảo cập nhật các điều khiển có liên quan

Thông qua thuộc tính dữ liệu

Sử dụng các thuộc tính dữ liệu để dễ dàng kiểm soát vị trí của băng chuyền.

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
20 accepts the keywords
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
21 or
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
22, which alters the slide position relative to its current position. Alternatively, use
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
23 to pass a raw slide index to the carousel
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
24, which shifts the slide position to a particular index beginning with
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
25

The

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
26 attribute is used to mark a carousel as animating starting at page load. It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel

Qua JavaScript

Call carousel manually with

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
7

Tùy chọn

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to

$(document).off('.alert.data-api')
35, as in
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
28

Nametypedefaultdescriptionintervalnumber5000The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. pausestring . null"hover"If set to

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
29, pauses the cycling of the carousel on
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
30 and resumes the cycling of the carousel on
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
31. If set to
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
32, hovering over the carousel won't pause it. wrapbooleantrueWhether the carousel should cycle continuously or have hard stops. keyboardbooleantrueWhether the carousel should react to keyboard events

phương pháp

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
33

Initializes the carousel with an optional options

$(document).off('.alert.data-api')
43 and starts cycling through items

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
8

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
35

Cycles through the carousel items from left to right

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
36

Stops the carousel from cycling through items

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
37

Cycles the carousel to a particular frame (0 based, similar to an array)

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
38

Cycles to the previous item

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
39

Chu kỳ đến mục tiếp theo

Events

Bootstrap's carousel class exposes two events for hooking into carousel functionality

Both events have the following additional properties

  • $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    40. The direction in which the carousel is sliding (either
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    41 or
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    42)
  • $(document).off('.alert.data-api')
    27. The DOM element that is being slid into place as the active item

All carousel events are fired at the carousel itself (i. e. at the

$(document).off('.alert.data-api')
05)

Event TypeDescriptionslide. bs. carouselThis event fires immediately when the

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
45 instance method is invoked. slid. bs. carouselThis event is fired when the carousel has completed its slide transition

var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i
var DefaultWhitelist = {
  // Global attributes allowed on any supplied element below.
  '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  a: ['target', 'href', 'title', 'rel'],
  area: [],
  b: [],
  br: [],
  col: [],
  code: [],
  div: [],
  em: [],
  hr: [],
  h1: [],
  h2: [],
  h3: [],
  h4: [],
  h5: [],
  h6: [],
  i: [],
  img: ['src', 'alt', 'title', 'width', 'height'],
  li: [],
  ol: [],
  p: [],
  pre: [],
  s: [],
  small: [],
  span: [],
  sub: [],
  sup: [],
  strong: [],
  u: [],
  ul: []
}
9

Thí dụ

The affix plugin toggles

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
46 on and off, emulating the effect found with . The subnavigation on the right is a live demo of the affix plugin


Usage

Use the affix plugin via data attributes or manually with your own JavaScript. In both situations, you must provide CSS for the positioning and width of your affixed content

Note. Do not use the affix plugin on an element contained in a relatively positioned element, such as a pulled or pushed column, due to a Safari rendering bug

Positioning via CSS

The affix plugin toggles between three classes, each representing a particular state.

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
48,
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
49, and
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
50. You must provide the styles, with the exception of
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
46 on
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
48, for these classes yourself (independent of this plugin) to handle the actual positions

Here's how the affix plugin works

  1. To start, the plugin adds
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    49 to indicate the element is in its top-most position. At this point no CSS positioning is required
  2. Scrolling past the element you want affixed should trigger the actual affixing. This is where
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    48 replaces
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    49 and sets
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    46 (provided by Bootstrap's CSS)
  3. If a bottom offset is defined, scrolling past it should replace
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    48 with
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    50. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add
    $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
    59 when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there

Follow the above steps to set your CSS for either of the usage options below

Thông qua thuộc tính dữ liệu

To easily add affix behavior to any element, just add

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
60 to the element you want to spy on. Use offsets to define when to toggle the pinning of an element

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
0

Qua JavaScript

Call the affix plugin via JavaScript

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
1

Tùy chọn

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to

$(document).off('.alert.data-api')
35, as in
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
62

Nametypedefaultdescriptionoffsetnumber . function . object10Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and bottom directions. To provide a unique, bottom and top offset just provide an object

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
63 or
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
64. Use a function when you need to dynamically calculate an offset. targetselector . node . jQuery elementthe
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
65 objectSpecifies the target element of the affix

phương pháp

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
66

Activates your content as affixed content. Accepts an optional options

$(document).off('.alert.data-api')
43

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
2

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
68

Recalculates the state of the affix based on the dimensions, position, and scroll position of the relevant elements. The

$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
48,
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
49, and
$.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
50 classes are added to or removed from the affixed content according to the new state. This method needs to be called whenever the dimensions of the affixed content or the target element are changed, to ensure correct positioning of the affixed content

var myDefaultWhiteList = $.fn.tooltip.Constructor.DEFAULTS.whiteList

// To allow table elements
myDefaultWhiteList.table = []

// To allow td elements and data-option attributes on td elements
myDefaultWhiteList.td = ['data-option']

// You can push your custom regex to validate your attributes.
// Be careful about your regular expressions being too lax
var myCustomRegex = /^data-my-app-[\w-]+/
myDefaultWhiteList['*'].push(myCustomRegex)
3

Events

Bootstrap's affix plugin exposes a few events for hooking into affix functionality

Event TypeDescriptionaffix. bs. affixThis event fires immediately before the element has been affixed. affixed. bs. affixThis event is fired after the element has been affixed. gắn trên cùng. bs. affixSự kiện này kích hoạt ngay trước khi phần tử được gắn vào-top. gắn trên cùng. bs. affixSự kiện này được kích hoạt sau khi phần tử đã được gắn vào-top. dưới cùng. bs. affixSự kiện này kích hoạt ngay trước khi phần tử được gắn-bottom. đáy cố định. bs. affixSự kiện này được kích hoạt sau khi phần tử đã được gắn-bottom