Skip to content

Commit

Permalink
fixed compatiblity with bootstrap accordions
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Dec 12, 2023
1 parent 5465fd6 commit f8f027a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## [1.8.4] - 2023-12-12
- Fixed: slick sliders in bootstrap accordions not initialized

## [1.8.3] - 2023-12-01
- Fixed: warnings

Expand Down
13 changes: 9 additions & 4 deletions src/Resources/assets/js/contao-slick-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ class SlickBundle
{
static initPage()
{
document.querySelectorAll('.slick').forEach((element) => {
SlickBundle.initElement(document);
}

static initElement(element)
{
element.querySelectorAll('.slick').forEach((element) => {
SlickBundle.initSlickElement(element);
});
}
Expand Down Expand Up @@ -67,6 +72,9 @@ class SlickBundle
// Todo: Remove in next major version
let collapse = $(element).closest('.collapse');
if (collapse.length > 0 && !collapse.hasClass('show')) {
collapse.on('shown.bs.collapse', () => {
SlickBundle.initSlickElement(collapse[0]);
});
console.log("Checking for collapse in slick bundle is deprecated and will be removed in next major version. Use beforeInit event instead.");
return;
}
Expand Down Expand Up @@ -118,7 +126,4 @@ if (document.readyState !== 'loading') {
// @todo: Remvoe in next major version
$(document).on('shown.bs.modal', '.modal', SlickBundle.initPage);

// @todo: Remove in next major version
$(document).on('shown.bs.collapse', '.collapse', SlickBundle.initPage);

document.addEventListener('huh.list.list_update_complete', SlickBundle.initPage);

0 comments on commit f8f027a

Please sign in to comment.