Forum Discussion

CDavidOrr's avatar
CDavidOrr
Cloud Apps
01-19-2022
Solved

BloX Notification When Data Loaded Due To Scroll

I have a BloX widget that builds a simple table of name/value pairs.  The data has 16 rows and I have showCarousel set to false so all data is displayed.  When the widget is rendered, only the first ...
  • harikm007's avatar
    01-20-2022

    CDavidOrr 

    Try `MutationObserver`, the function will get executed whenever DOM changes.

    widget.on('ready', function(se, ev) {
    	/*
    		Your existing script. No need to change this.
    	*/
    
    	//Observer
    	const elementToObserve = $('.scroll .content div', element)[0];
    	const observer = new MutationObserver(function(e) {
    		for(const m of e) {
    			if (m.type === 'childList') {
    				//Copy your script to change style.
    				//Added element will be 'm.addedNodes'. So you can apply style on 'e.addedNodes'
    				//example : $(m.addedNodes).find('.text-block').css('color', 'green')
    			}
    		}
    	});
    	observer.observe(elementToObserve, {subtree: true, childList: true});
    })

    -Hari