Skip to content

Instantly share code, notes, and snippets.

@alexiglesias93
Last active July 20, 2022 18:41
Show Gist options
  • Save alexiglesias93/044ab9f442bcb985b7d243ce133a918d to your computer and use it in GitHub Desktop.
Save alexiglesias93/044ab9f442bcb985b7d243ce133a918d to your computer and use it in GitHub Desktop.
`cmsload` API
/**
* Interacting with list items in `cmsload`.
*/
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'cmsload',
(listInstances) => {
console.log('cmsload Successfully loaded!');
// `listInstances` holds an array with all the CMS Lists using `cmsload` on the page.
const [listInstance] = listInstances;
/**
* The `additems` event runs whenever new items are added to the list after loading them (but not necessarily rendered on the DOM).
* If an item has been loaded in the background but should not be displayed yet, it's kept in memory instead of rendering it.
*/
listInstance.on('additems', (addedItems) => {
console.log(addedItems);
});
/**
* The `renderitems` event runs whenever any items are shown/hidden (rendered) in the list.
* This is triggered when:
* - Switching the current page in `pagination` mode.
* - Loading more items in `load-under` and `infinite` modes.
* - Rendering all items in `render-all` mode.
*/
listInstance.on('renderitems', (renderedItems) => {
console.log(renderedItems);
});
},
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment