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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Add JavaScript to mode...
Power Pages
Answered

Add JavaScript to modern lists

(1) ShareShare
ReportReport
Posted on by 104

Hi,

 

I am using the new modern list component that is in preview right now. It looks really good compared to the old one.

I would like to add some JavaScript to the list, but I can not identify what would be the right function to identify it. As for the old list component, the function started always like this:


$(document).ready(function (){ $(".entitylist.entity-grid").on("loaded", function () {
........

 

I tried using different classes from the Inspect Element which I thought would identify correctly the list, but no luck.

Any ideas what would be the new structure?

 

Thank you.

Categories:
I have the same question (0)
  • vitalii_hladkyi Profile Picture
    10 on at

    I have the same issue. Looks like modern lists doesn't load js files from "lists" forler at all.
    Anyone found workaround?

  • Verified answer
    Inogic Profile Picture
    1,135 Super User 2025 Season 2 on at

    Hi,

     

    The new Layout control opens new grounds to discover how to customize the grid with custom CSS and SCRIPTS,

     

    We have optimized the grid with the below JavaScript simple logic which works pretty well,

     

    Navigate to the Visual Studio for the target Web page from the Design Studio,

     

    Inogic_0-1718108723039.jpeg

     

     

    Paste the given Code Snippet in the Js file of the Target Web page,

     

    Inogic_1-1718108723041.jpeg

     

    let list_interval = setInterval(() => { ... }, 100);: This sets up a repeated action that runs every 100 milliseconds. The action checks if any elements with the attribute data-automationid="DetailsRowCell" exist in the DOM.

    Once the element is loaded clearInterval removes the interval.

    list_interval is wrapped into the GridOptimization() which is called within once document is loaded.

     

    $(document).ready( ()=> {

        GridOptimization();

    });

    function GridOptimization() {

        let list_interval = setInterval( ()=> {

            if ($('div[data-automationid="DetailsRowCell"]').length != 0) {

                    //You can add your logic here.

                $(".ms-DetailsRow-fields.fields-213").css("color", "blue")

                clearInterval(list_interval);

            }

        }, 100)

    }

     

    Save and Sync the Power Pages site,

     

    After Save and Sync, the Portal looks like below where the change we tried to achieve was to change the font of data present in the list using javascript.

    Inogic_2-1718108810513.jpeg

    Hope this helps.

     

    Thanks!

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com
    Service: https://www.inogic.com/services/
    Tips and Tricks: https://www.inogic.com/blog/
  • vitalii_hladkyi Profile Picture
    10 on at

    Hi!
    It make sence, but it won't work if user will try to sort items. It would be great if there was some kind of event, like on old lists "onload" event, so the code will fire after items are loaded
    But I got your idea, thanks!

  • Inogic Profile Picture
    1,135 Super User 2025 Season 2 on at

    Hi,

     

    Glad our solution helped.

     

    Thanks!

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com
    Service: https://www.inogic.com/services/
    Tips and Tricks: https://www.inogic.com/blog/
  • Fubar Profile Picture
    8,346 Super User 2025 Season 2 on at

    As it doesn't load the same way as a standard list no idea if there is any plans to add things like onloaded events or not, in the meantime rather than a timer, you should also be able to use a javascript MutationObserver which lets you catch changes to the DOM.

  • vitalii_hladkyi Profile Picture
    10 on at

    Thanks!

    MutationObserver in combination with setInterval works perfect for me

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 70 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard