Alrighty… so there’s a couple things going on here. First, I’m trying to create a global object called myScrolls. Second, I’m trying to set the value of that global object inside a jQuery load function. Third, I’m trying to access the myScrolls object outside of the load object.
What am I missing? Do the ‘for’ loops have limited scope?
Thanks
myScrolls=new Object();
$(window).load(function () {
var projectCount = 5;
for (var i=0;i<=projectCount;i++)
{
var singleProject = 'project_' + i;
myScrolls[singleProject] = new iScroll(singleProject, horizontalPreferences);
}
});
console.log(myScrolls);
You’re trying to read the object before the
loadcallback executes.