Can't get snippet to run on page load

You actually want this snippet to run AFTER page load,  because you need the model data to be available.  This is why it runs successfully from the console.  Models have loaded etc.  You need to wrap your snippet in a function that waits for the page to load before executing.  Somthing like this: 

(function(skuid){ var $ = skuid.$; $(function(){ Your Function goes here...... }); })(skuid);


Actually if you create a new Javascript resource of type Inline you will get this code prepopulated for you.