The OnReady function
The OnReady
function is a jQuery event that runs as soon as the DOM is ready for JavaScript code to execute. This is important in Power Pages as it ensures that the JavaScript or jQuery code executes after the full web page is loaded, preventing any potential errors or mishaps.
Implementing the OnReady function
Sarah decides to create an example to manage fields in the incident edit basic form. The OnReady
function event has the following syntax and function signature. To do this, Sarah must follow these steps:
- Open Power Pages Studio.
- Edit the website from the list of websites in this environment.
- Select the Edit Code button. This will open Visual Studio Code in a browser window.
- Browse to the basic-forms tab, as shown in Figure 7.1:
Figure 7.1 – Visual Studio Code basic-forms
- Select the Incident basic form to edit its script.
- Type in the following code:
$(document).ready(function() { ...