Dynamically load Copy to Clipboard

Hi,

I’m using the Copy to Clipboard combined with the CMS Load (in render-all) attributes.

Since it takes some time to render all items with CMS Load (I have more than 100), the copy to clipboard library only works with the first 100 displayed items, but fails to dynamically load with the next rendered items.

So I was wondering if there was a way to delay the execution of the library or to execute it in another way rather than just including the script in the headers? Thanks.

hey @hello13! You can prevent the attribute from loading by adding this setting to the Copy to Clipboard script defer fs-attributes-preventload='true'.

Then this callback function will run after CMS Load has successfully loaded and initialize the Copy to Clipboard Attribute

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