Run code when tab loads

Zach, I have a very similar situation. I need some javascript to run on a page when it loads as an include in a popup. The page functions fine when I run it by it self - the code below runs when the page loads:

$j(document).load ( function() { var models = skuid.model; var $ = skuid.$; var workshopRow = models.getModel('WorkshopDetail').getFirstRow(); ... 

However, when I have a popup (from a calendar) that includes this page, the code seems to execute before the models load. I get an error on the getModel() line when I click to load the popup saying that there is no such model yet. How can I modify this to get the code to execute after the included page’s models load?