I would just use jQuery:
<tr:document>
<trh:script source="jquery.js"></trh:script>
<trh:script source="your_script.js"></trh:script>
...
</tr:document>
You can then just execute your script on page load (.ready
):
$(document).ready(function(){
// Your stuff here
});
If you are using Ajax (Trinidad Partial Page Rendering), you might want to add a state change listener in your Javascript. For example:
TrPage.getInstance().getRequestQueue().addStateChangeListener(function(state){
if (state == TrRequestQueue.STATE_READY){
// Your stuff here
}
});