0

I built an accordion from the Magento 2 documentation.

CODE JS:

$(".init-accordion").accordion({
    "active": [1, 2],
    "collapsible": true,
    "openedState": "active",
    "multipleCollapsible": true,
    dimensionsChanged: function(event, data) {
        var opened = data.opened;

        if (opened) {
            // do something when the content is opened
            return;
        }
        // do something when the content is closed
    }
}); 

The accordion works but the dimensionsChanged callback does not work.

Magento 2 documentation accordion

Does anyone know why and how can I make it work?

Thanks!

1 Answer 1

0
use below code.. it might works for you.

$(".init-accordion").accordion({
    "active": [1, 2],
    "collapsible": true,
    "openedState": "active",
    "multipleCollapsible": true,
}); 
$(".init-accordion").on("dimensionsChanged", function (event, data) {
    var opened = data.opened;

    if (opened) {
        // do something when the content is opened
        return;
    }
    // do something when the content is closed
});
1
  • I tried it before posting and it still doesn't work, is it a Magento bug?
    – Cristian
    May 26, 2021 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.