Bootstrap slider not working with HubSpot custom module wrappers

I’m having trouble with my Bootstrap slider inside a HubSpot custom module. HubSpot automatically wraps all custom modules with extra div and span elements, which breaks the carousel functionality.

The Bootstrap carousel expects direct child elements with the ‘slide’ class, but HubSpot adds these wrapper containers between the carousel container and my actual slide content. How can I modify the carousel initialization to work with these nested wrappers?

Here’s what the structure looks like after HubSpot processes it:

<div class="slider-container">
    <!-- HubSpot wrapper span -->
    <span id="hs_cos_wrapper_slider_content" class="hs_cos_wrapper hs_cos_wrapper_widget_container" data-hs-cos-general-type="widget_container">
        <!-- HubSpot wrapper div for each slide -->
        <div id="hs_cos_wrapper_module_1234567890" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_custom_widget" data-hs-cos-general-type="widget">
            <!-- My actual slide content -->
            <div class="slide active">
                <div class="banner" style="height: 500px; background-image: url(photo.jpg);">
                    <div class="content-wrapper">
                        <h2>Sample Banner Text</h2>
                    </div>
                </div>
            </div>
        </div>
    </span>
</div>

Any suggestions on how to target the nested slide elements properly?

hubspot’s wrapper mess is annoying. use event delegation - attach your carousel events to the document and let them bubble up through the nested divs. also check that your carousel’s data attributes aren’t getting lost as they pass thru those wrappers.

HubSpot updates mess up the wrapper issue even more. Instead of fixing selectors every few months, I switched approaches and it’s way better. Build your carousel completely outside HubSpot’s module system using their content API. Write a simple script that pulls slide data from HubSpot and creates the carousel markup in vanilla HTML. This skips all the wrapper crap entirely. Your Bootstrap carousel gets clean DOM structure and HubSpot still handles content through their CMS. Way less maintenance since you’re not fighting their template rendering weirdness anymore.

Wrap your carousel init in a MutationObserver - it’ll catch when HubSpot finishes loading those wrapper elements. Then use closest() to navigate back up the DOM tree from your slide content. Fixed the same issue for me when regular selectors kept breaking after HubSpot updates.

HubSpot’s wrapper divs are annoying, but don’t waste time fighting nested selectors.

Skip working around HubSpot’s messy DOM - automate the whole slider setup instead. Had this same problem with a client last year. Built an automation that pulls content straight from HubSpot’s API and renders clean carousel markup on the frontend.

The automation watches for HubSpot content updates and rebuilds the slider without those wrapper elements. You control the HTML output and Bootstrap works perfectly.

You’re not stuck with HubSpot’s rendering quirks anymore. Future changes to their wrapper structure won’t break your carousel. You can add dynamic content loading, A/B test slide orders, or auto-optimize images.

I use Latenode for HubSpot integrations - handles API connections smoothly and transforms data however you need before hitting your frontend. Way cleaner than DOM hacks.

Yeah, the wrapper structure breaks Bootstrap’s carousel indicators and nav controls. I ran into this and had to override Bootstrap’s defaults by changing the data-target attributes after page load. Use jQuery to dig through those HubSpot wrappers and fix the carousel’s slide references. Try something like $(‘.carousel’).each(function() { $(this).find(‘.carousel-indicators li’).attr(‘data-target’, ‘#’ + this.id); }) once the DOM loads. Also heads up - the slide animations get choppy because of the extra wrapper positioning. You might need transform: translateZ(0) on the HubSpot wrapper elements to force hardware acceleration. Let HubSpot load first, then clean up the carousel references.

Been through this exact thing with a HubSpot migration. Don’t initialize the carousel on the outer container - target the actual slide content inside those HubSpot wrappers instead. Change your JavaScript to something like $(‘.slider-container’).find(‘.slide’) so it finds your slides no matter how many wrapper layers there are. You’ll also need to fix your CSS since those wrapper elements mess with Bootstrap’s carousel styling. Set the HubSpot wrapper spans to display: contents or tweak the positioning on wrapper divs to keep everything flowing right. Same goes for carousel controls and indicators - make sure they’re targeting the right slide elements. Takes some tweaking but works great once you get it dialed in for HubSpot’s structure.

Encountered a similar issue when integrating a Bootstrap slider with HubSpot. The extra wrapper elements complicate things but modifying your approach can lead to a solution. Instead of directly setting up the carousel with its default initializations, update your JavaScript to target the nested slide elements directly. For instance, use a selector like ‘.slider-container .slide’ to access the intended content. You’ll likely need to tweak the CSS as well, since the added wrappers affect the layout. This approach allows the carousel to function properly without fighting against HubSpot’s structure.

The nested wrapper structure is challenging, but you can still utilize HubSpot’s module system effectively. One way to do this is by reinitializing the carousel after HubSpot loads its elements. Consider using setTimeout or listening to HubSpot’s page events so that you can accurately select your slide elements with document.querySelectorAll(‘.slider-container .slide’). Keep in mind HubSpot’s unique loading sequence. Additionally, you should refine your Bootstrap CSS selectors to navigate through the wrapper layers; for instance, target .carousel .hs_cos_wrapper .slide instead of just .carousel .slide. This approach ensures that you can leverage HubSpot’s content management while ensuring the carousel operates properly. Although it’ll load slower, it helps maintain the integration.

Those wrapper elements don’t just mess up Bootstrap carousels - they break image galleries, accordions, and anything that needs specific DOM structure.

Stop wrestling with CSS hacks and jQuery selectors every time HubSpot changes things. Just automate the whole content delivery instead. Pull your slider content through HubSpot’s API and render it outside their templating system.

Set up automation that grabs slide data from HubSpot and delivers clean HTML to your carousel. No wrapper divs, and Bootstrap gets exactly what it expects.

You get way more control this way. Cache slider content for faster loading, auto-resize images, or personalize slide order based on visitor behavior.

Latenode makes HubSpot API integrations simple and handles the data transformation to format content for your frontend. Way more reliable than hoping CSS tricks survive HubSpot’s next update.

Those HubSpot wrappers change constantly with updates. I’ve hit this on three projects and got tired of fixing the same selectors repeatedly.

Skip the wrapper workaround entirely. Build automation that syncs HubSpot content to a clean carousel. Pull slide data from HubSpot when editors update content, then render clean Bootstrap markup without wrapper elements.

Your carousel gets the exact DOM structure it needs. Bootstrap works perfectly. Editors keep using HubSpot’s interface.

Bonus - add lazy loading or dynamic slide ordering based on performance. Way better than debugging nested divs every time HubSpot updates.

I use Latenode for this kind of HubSpot integration. Connects cleanly to their API and transforms content into whatever format your frontend needs. Much more reliable than DOM gymnastics.