javascript $.each loop not executing

I’m attempting to loop through the rows in a model I have in javascript. Here is the code I’m running:

var params = arguments[0], $ = skuid.$;
console.log(‘Oh Yeah!!!’);
var modelStuff = skuid.model.getModel(‘modelName’);
$.each(,function(i,row) {
    console.log(‘Oh No!!!’);

Both of my console.log(modelStuff) calls before and after the loop show that the model has two rows with data, but I never get 'Oh No!!!'

This is basically copy pasta straight from an example found in another question here. How can I show data (2 rows to be exact) in both of my console.logs but not ever execute the loop on…

Also, if I run modelStuff.getRows() it returns an empty array…

Hi Jerry,

It looks like the weird logging behavior that you’re seeing is because of how your browser’s console works. In reality, at the time your code runs, the model has no rows. When you log a reference to the model, Chrome’s console is actually showing you the state of the model at a later time.

How is that snippet being invoked? Is it part of a row action?

Thanks Ben, and yes. The snippet I’m running gets called when things are added to that model. I’ve actually gotten past this and was just about to update this question.

I solved my problem by wrapping the whole thing in one of these guys:

       things and stuff;

Not sure how to mark a question solved though…

Glad you figured it out. Actually, you don’t actually need to use $.when() in this case. Since updateData() returns a promise, you should be able to just use the code below…

modelStuff.updateData().then(function(){ //things and stuff; });

Cool, I’ll give that a try.