mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-14 18:42:30 +03:00
Docs: update documentation js examples, using es6 (#36203)
* Docs: update components documentation using es6 * Docs: update js blocks around docs, using es6 * Docs: update components documentation using es6 * Test linter
This commit is contained in:
@@ -1050,10 +1050,8 @@ Add `data-bs-toggle="dropdown"` to a link or button to toggle a dropdown.
|
||||
Call the dropdowns via JavaScript:
|
||||
|
||||
```js
|
||||
var dropdownElementList = Array.prototype.slice.call(document.querySelectorAll('.dropdown-toggle'))
|
||||
var dropdownList = dropdownElementList.map(function (dropdownToggleEl) {
|
||||
return new bootstrap.Dropdown(dropdownToggleEl)
|
||||
})
|
||||
const dropdownElementList = document.querySelectorAll('.dropdown-toggle')
|
||||
const dropdownList = [...dropdownElementList].map(dropdownToggleEl => new bootstrap.Dropdown(dropdownToggleEl))
|
||||
```
|
||||
|
||||
{{< callout info >}}
|
||||
@@ -1082,9 +1080,9 @@ Regardless of whether you call your dropdown via JavaScript or instead use the d
|
||||
#### Using function with `popperConfig`
|
||||
|
||||
```js
|
||||
var dropdown = new bootstrap.Dropdown(element, {
|
||||
popperConfig: function (defaultBsPopperConfig) {
|
||||
// var newPopperConfig = {...}
|
||||
const dropdown = new bootstrap.Dropdown(element, {
|
||||
popperConfig(defaultBsPopperConfig) {
|
||||
// const newPopperConfig = {...}
|
||||
// use defaultBsPopperConfig if needed...
|
||||
// return newPopperConfig
|
||||
}
|
||||
@@ -1119,8 +1117,8 @@ All dropdown events are fired at the toggling element and then bubbled up. So yo
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
var myDropdown = document.getElementById('myDropdown')
|
||||
myDropdown.addEventListener('show.bs.dropdown', function () {
|
||||
const myDropdown = document.getElementById('myDropdown')
|
||||
myDropdown.addEventListener('show.bs.dropdown', event => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user