How to load a UI Script after the entire dom is ready

raskill
Kilo Contributor

I have a UI script that I have made available to an application portal. The issue that I'm facing currently is that the UI script code is being loaded before the entire dom is ready. As a result, any reference to a dom element in the script would give me the following,

find_real_file.png

How can I load the code in the UI Script after the entire dom is ready?

Any help with this is greatly appreciated!

Thanks,

Raskill 

 

5 REPLIES 5

ARG645
Tera Guru
var $j = jQuery.noConflict(true);

$j(document).ready(function () {

   //Add your code here

});

raskill
Kilo Contributor

I tried using jQuery and it did not work. It does not even load my portal page infact.

 

Thanks,

Raskill

Try addLoadEvent() its an OOB ServiceNow API

addLoadEvent(loadMe);

   function loadMe(){


   //Add your Code Here


}

 


Hope that helps!

raskill
Kilo Contributor

Hi Aman,

 

This did not work either šŸ˜ž I see that my sample.jsdbx file is already loaded before the catalog form loads in the portal. Any other alternate approach?

 

Thanks,

Raskill