smartclient

Run a function on page load using SmartClient


When the page loads, I want to hide some buttons based on user permissions.

I have a function that does what I need, but currently I have to press a button to call it.

How to run a applyUserPermissions function right after page loads using SmartClient?

function applyUserPermissions(){
    btn.setDisabled(false);
}

Solution

  • Same as in plain Javascript

    The statements are executed, one by one, in the same order as they are written.

    ~ w3c Javascript School

    So like this:

    <script>
    
    function applyUserPermissions(){
        btn.setDisabled(false);
    }
    
    // calls it on page load
    applyUserPermissions();
    
    </script>