Solution
Document.ready function is for this purpose. For example, you want to call a function that fills a drop-down dynamically when the view loads, you will give that function a call in document.ready function enclosed in the script tag
<script>
$(document).ready(function () {
fillRoles();
});
</script>
In the above example, function fillRoles() is called to fill the Roles drop-down as soon as the form loads. Similarly, you can place all your code that needs to execute at this stage
Leave a comment