Skip to content

Uncaught TypeError: locations.each is not a function in Magento admin showing occasionally on system configuration page in 2.4.5

While accessing a Magento admin system configuration page, facing the below error that prevents the save config button.

Uncaught TypeError: locations.each is not a function

When clicking on system.js, seems to be loading from the PayPal_Braintree module.

locations.each(function (loc) {
        $('[data-ui-id="select-groups-braintree-section-groups-braintree-groups-braintree-paypal-groups-styling-groups-button-'+loc+'-fields-paypal-location-'+loc+'-button-type-value"]').change(function () {
            hidePaypalSections();
        });
    });