tp.Ready

tp.Ready() is the normal place for application startup code. The callback runs after the browser has completed the document initialization cycle and the page is ready for JavaScript code that needs real elements.

Inside a tp.Ready() callback you can find DOM elements, create Tripous components, attach DOM or Tripous event handlers, read initial values, apply layout setup, and start the first application workflow. If the page is already ready when tp.Ready() is called, the callback runs immediately.

A page may register as many tp.Ready() callbacks as needed. They execute in the same order the browser finds and parses those registrations in the page scripts.

Typical use

tp.Ready(function () {
    var Button = tp("#SaveButton");
    var NameBox = new tp.TextBox("#Name");

    tp.On(Button, "click", function () {
        Save(NameBox.Text);
    });
});

The callback above can safely use #SaveButton and #Name because the document is ready when it runs.

Observed behavior