From dc5e3328c12058de7fb6404edbe5dcee61f3400f Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Mon, 22 Feb 2021 12:31:04 +0530 Subject: Allow constructors to accept a CSS selector (#32245) Co-authored-by: XhmikosR Co-authored-by: Mark Otto --- site/content/docs/5.0/getting-started/javascript.md | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'site/content/docs/5.0/getting-started/javascript.md') diff --git a/site/content/docs/5.0/getting-started/javascript.md b/site/content/docs/5.0/getting-started/javascript.md index 53845fdfc..f57a3aedf 100644 --- a/site/content/docs/5.0/getting-started/javascript.md +++ b/site/content/docs/5.0/getting-started/javascript.md @@ -93,6 +93,15 @@ var modal = new bootstrap.Modal(myModalEl, { keyboard: false }) // initialized w If you'd like to get a particular plugin instance, each plugin exposes a `getInstance` method. In order to retrieve it directly from an element, do this: `bootstrap.Popover.getInstance(myPopoverEl)`. +### CSS selectors in constructors + +You can also use a CSS selector as the first argument instead of a DOM element to initialize the plugin. Currently the element for the plugin is found by the `querySelector` method since our plugins support a single element only. + +```js +var modal = new bootstrap.Modal('#myModal') +var dropdown = new bootstrap.Dropdown('[data-bs-toggle="dropdown"]') +``` + ### Asynchronous functions and transitions All programmatic API methods are **asynchronous** and return to the caller once the transition is started but **before it ends**. -- cgit v1.2.3 From 9485172017868952047da5f188bc13a92ef0435d Mon Sep 17 00:00:00 2001 From: Matt Dufresne Date: Tue, 15 Jun 2021 08:43:24 -0400 Subject: fix error in javascript example under Asynchronous functions and transitions section --- site/content/docs/5.0/getting-started/javascript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'site/content/docs/5.0/getting-started/javascript.md') diff --git a/site/content/docs/5.0/getting-started/javascript.md b/site/content/docs/5.0/getting-started/javascript.md index f57a3aedf..8ee428921 100644 --- a/site/content/docs/5.0/getting-started/javascript.md +++ b/site/content/docs/5.0/getting-started/javascript.md @@ -109,7 +109,7 @@ All programmatic API methods are **asynchronous** and return to the caller once In order to execute an action once the transition is complete, you can listen to the corresponding event. ```js -var myCollapseEl = document.getElementById('#myCollapse') +var myCollapseEl = document.getElementById('myCollapse') myCollapseEl.addEventListener('shown.bs.collapse', function (event) { // Action to execute once the collapsible area is expanded -- cgit v1.2.3 From f20fece3a8cdd0e76a42c2737524b7652bf54d26 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 4 Aug 2021 18:41:51 +0300 Subject: Prepare v5.1.0. (#34674) --- .../content/docs/5.0/getting-started/javascript.md | 238 --------------------- 1 file changed, 238 deletions(-) delete mode 100644 site/content/docs/5.0/getting-started/javascript.md (limited to 'site/content/docs/5.0/getting-started/javascript.md') diff --git a/site/content/docs/5.0/getting-started/javascript.md b/site/content/docs/5.0/getting-started/javascript.md deleted file mode 100644 index 8ee428921..000000000 --- a/site/content/docs/5.0/getting-started/javascript.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -layout: docs -title: JavaScript -description: Bring Bootstrap to life with our optional JavaScript plugins. Learn about each plugin, our data and programmatic API options, and more. -group: getting-started -toc: true ---- - -## Individual or compiled - -Plugins can be included individually (using Bootstrap's individual `js/dist/*.js`), or all at once using `bootstrap.js` or the minified `bootstrap.min.js` (don't include both). - -If you use a bundler (Webpack, Rollup...), you can use `/js/dist/*.js` files which are UMD ready. - -## Using Bootstrap as a module - -We provide a version of Bootstrap built as `ESM` (`bootstrap.esm.js` and `bootstrap.esm.min.js`) which allows you to use Bootstrap as a module in your browser, if your [targeted browsers support it](https://caniuse.com/es6-module). - -```html - -``` - -{{< callout warning >}} -## Incompatible plugins - -Due to browser limitations, some of our plugins, namely Dropdown, Tooltip and Popover plugins, cannot be used in a `