Is it possible to run a custom callback function once more CMS items are finished loading?
It should be like this:
1 - User clicks on “load more” button
2 - Attributes get the items from CMS
3 - Once they loaded and the call has finished, I run my callback
Hey @vierless_julian! You cann use the CMS Load API callback to run any code after the solutions has loaded successfully!
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'cmsload',
(listInstances) => {
console.log('cmsload Successfully loaded!');
// The callback passes a `listInstances` array with all the `CMSList` instances on the page.
const [listInstance] = listInstances;
// The `renderitems` event runs whenever the list renders items after switching pages.
listInstance.on('renderitems', (renderedItems) => {
console.log(renderedItems);
});
},
]);
You can read more here!
Ok, got it. In my case I want to lazy load iframes in my items. Therefore I need to know when I loaded the next ones. So if I just use the callback, then I could not get the new items to update.
Yes, the renderitems
is fired every time new items are rendered on the page and you can loop over the renderedItems
loading the iframe on them. If you already have the code to load the items I can share how it should look like