Last active
July 20, 2022 18:41
-
-
Save alexiglesias93/044ab9f442bcb985b7d243ce133a918d to your computer and use it in GitHub Desktop.
`cmsload` API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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