here are few events that could be helpful
block-loaded event is triggered when React mounts the block into DOM. It can be used instead of DOMContentLoaded event that is used in old custom codes.
window.addEventListener('block-loaded-table1', () => {
console.log('Block loaded');
});
get-records event is triggered on every data response from softr data service. It can be used for getting the data manipulating before it get’s rendered.
const onRecords = (e) => {
// we got new data under e.details
console.log(e.detail);
//console.log [{id: '***', fields: {...}}]
};
window.addEventListener('get-records-table1', onRecords);
const onRecords = (e) => {
setTimeout(() => {
// The block finish rendering
// I may do some staff here.
}, 50);
};
window.addEventListener('get-records-table1', onRecords);
get-records:before event that is triggered before sending request, It can be used to catch the inline filter or search field changes.
const onFilterChange = (e) => {
console.log(e.detail);
//console.log { search: '', filter: [ { field: 'size', value: 'M' } ] }
};
window.addEventListener('get-records-table1:before', onFilterChange);
Note: table1 is the block name in studio settings