web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Adding onload event to...
Power Pages
Suggested Answer

Adding onload event to "Modern" lists

(2) ShareShare
ReportReport
Posted on by 2
I am able to easily add an onload event to regular lists on Power pages like this:
 
$(document).ready(function () {
    $(".entity-grid.subgrid").on("loaded", function () {
        //do something with list rows    
    });
});
 
however this does not work for modern lists.  I read that I can possibly use a mutation observer, but is that the solution I should be using or is there something I am missing?
Any help would be greatly appreciated.
 
 

 
Categories:
I have the same question (0)
  • Suggested answer
    Jon Unzueta Profile Picture
    1,836 Super User 2026 Season 1 on at
     

    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.


     Why MutationObserver Is a Valid Solution

    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.


     How to Use MutationObserver in Power Pages

    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);

    });

    🔍 Tips for Success

    • Inspect the DOM of your modern list to find the correct container and row selectors.
    • Use browser dev tools to identify when and how the list is rendered.
    • You can also debounce or throttle your logic if the observer fires too frequently.

     

    🏷️ Tag me if you have any further questions or if the issue persists.
    ✅ Click "Accept as Solution" if my post helped resolve your issue—it helps others facing similar problems.
    ❤️ Give it a Like if you found the approach useful in any way.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 48

#2
Valantis Profile Picture

Valantis 24

#2
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard