Executing code after CMS Load finishes loading all items

I would like to have some code execute after CMS Load completes loading all items. How would I do this using Javascript?

Hey @agarwala! You can use the CMS Load callback to run code after the Attribute load and each time the elements are rendered on the page.

Here is the code

<script>
  window.fsAttributes = window.fsAttributes || [];
  window.fsAttributes.push([
    'cmsload',
    (listInstances) => {
      console.log('cmsload Successfully loaded!');

      const [listInstance] = listInstances;

      //Code to run once after the Attribute loads goes here

      listInstance.on('renderitems', (renderedItems) => {
        console.log(renderedItems);
        //Code to run each time items are rendered goes here
      });
    },
  ]);
</script>

This worked perfectly @Support-Luis. Thank you!

You can see it in action here:

1 Like

Awesome! :muscle: