model is undefined on document ready

I’m running inline javascript on document ready which gets a model as follows:

        var showTabsModel = skuid.$M(‘ShowTabs’),
            showTabsRow = showTabsModel.getFirstRow();

// do some other things…


I’m getting an error which indicates that showTabsModel returns undefined. Load Model data on page load is checked for ShowTabs, and the only condition on the model is based on userinfo.

Any idea why showTabsModel would be coming back undefined?

Update: I’m running this page as a page include, from a queue.

When I run the page when I run the page as a stand-alone, everything works fine. When I run it as an include, i’m getting the javascript error (and a plank page).

In page includes you have to use the ‘pageload’ event shown here.…

Like a charm! Thanks, Ben.

@ben/ @Matt - I have the similar issue, but I am facing the problem in loading the model data from a button which is on the pageinclude page. tried $(document.body).one(‘pageload’), but page is not loading after added it. Any suggestions?


If you’re loading a model from a button, you don’t need the pageload function. Just set the actions for the button to include a query of your model.

Thank you @matt for the reply. I am able to resolve the issue. but one strange thing i figured is, if I am querying model from other models save callback methods like{callback: function(response1){
if(!response1.totalsuccess) {
var modelabc = skuid.$M(‘modelabc’);

in the above scenario variable modelabc is returning undefined. If I put the same statement outside save action it is working fine.

The above scenario is working if I am running included separately. Looks like I am missing something in this skuid approach. 



This may be a silly thing… but it’s worth checking that the if statement is processing as you expect it to. Your “var modelabc = skuid.$M(‘modelabc’);” line is only running if response1.totalsuccess is not true. You may want to just add


inside your if statement to make sure the if is working the way you expect.

agreed Matt. The above code is just an example for the issue I am explaining. whatever model query statements that I am placing inside callback methods are returning undefined. all the remaining statements in that block are running fine. Anyway for now, I figured out the work around. But trying to understand why this is an issue.

Appreciate your time Matt. Thanks

Nice. I generally have abandoned callback statements in favor of jquery $.when(), which seems to work more reliably.