
$(document).ready(function () {
$(".entity-grid.subgrid").on("loaded", function () {
//do something with list rows
});
});
You're absolutely right—modern lists in Power Pages (especially those rendered using the new Fluent UI or virtual tables) don't trigger the same loaded event as classic entity lists. So your jQuery on("loaded") approach won't work reliably.
Yes, using a MutationObserver is a recommended workaround for modern lists. Since these lists are rendered dynamically (often via React or Fluent UI components), you need to watch for DOM changes rather than rely on traditional load events.
Here’s a basic example of how you can use a MutationObserver to detect when rows are added to a modern list:
$(document).ready(function () {
const targetNode = document.querySelector(".modern-grid-container"); // Adjust selector as needed
if (!targetNode) return;
const config = { childList: true, subtree: true };
const callback = function (mutationsList, observer) {
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
// Check if rows are added
const rows = targetNode.querySelectorAll(".modern-grid-row"); // Adjust selector
if (rows.length > 0) {
console.log("Modern list rows loaded:", rows);
// Do something with the rows
}
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
});