Skip to content

Commit 8a1793a

Browse files
committed
[docs] Devdocs Bootstrap 5 compatibility jquery
1 parent 9f8da50 commit 8a1793a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/guides/bs5migration/index.md

+33
Original file line numberDiff line numberDiff line change
@@ -670,3 +670,36 @@ document.querySelectorAll('[data-bs-toggle="tab"]').forEach((tab) => {
670670
Although Bootstrap does not need jQuery anymore, it is still possible to use it in Moodle. See MDL-84324 for more information.
671671

672672
:::
673+
674+
## BS4 backwards-compatibility layer
675+
676+
The migration from Bootstrap 4 to Bootstrap 5 involves a transition period to allow third-party plugins to update gradually.
677+
To facilitate this, a backwards-compatibility layer has been created, ensuring that some Bootstrap 4 syntax will continue to function until final deprecation in Moodle 6.0.
678+
This approach aims to provide developers with sufficient time to adapt their code to the new Bootstrap 5 framework.
679+
680+
The BS4 backwards-compatibility layer encompasses three crucial aspects to facilitate a smooth transition for third-party contributions:
681+
682+
1. **Bootstrap jQuery support**: This allows existing plugins and components that rely on jQuery to continue functioning while developers work on updating their code to the new vanilla JavaScript approach.
683+
2. **SCSS helpers and utilities**: The compatibility layer includes some SCSS helpers and utilities from Bootstrap 4, enabling developers to gradually adapt their custom styles to the new Bootstrap 5.
684+
3. **Bootstrap 4 old data attributes syntax silent replacement**: This feature quietly replaces the old Bootstrap 4 data attribute syntax with the new Bootstrap 5 syntax, ensuring that existing markup continues to work without immediate changes.
685+
686+
### Bootstrap jQuery support
687+
688+
<Since version="5.0" issueNumber="MDL-84324" />
689+
690+
To ease the transition from Bootstrap 4 to Bootstrap 5, the backwards-compatibility layer maintains support for jQuery-dependent components.
691+
This allows developers to continue using existing jQuery-based plugins and custom code while gradually migrating to the new vanilla JavaScript approach introduced in Bootstrap 5.
692+
693+
The following examples illustrate how to use jQuery with Bootstrap 5 components:
694+
695+
```js
696+
$('[data-bs-toggle="tooltip"]').tooltip();
697+
```
698+
699+
Or with event listeners:
700+
701+
```js
702+
$('#myTab a').on('shown.bs.tab', function () {
703+
// do something...
704+
});
705+
```

0 commit comments

Comments
 (0)