I came across jQuery Knob the other day and it's perfect for a project I'm working on. Awesome work Anthony:
The object is to create a knob(s) and display on a page using data collected from an array of objects storing the required data.
What I need to achieve is looping through either a $.each(data, function... loop or a for loop, with a pause between each loop.
Something like this:
(function($) {
$.each(data, function(i, item) {
buildPage(item);
// Use a delay here of x number of seconds before looping again
}
)(jQuery);
I tried setIntervals and setTimeout, I did get it working at one stage, however all the css for the jquery-knob.js file wouldn't load, which is the important part as it draws the knobs.
I'm still pretty green when it comes to development so any examples w/ explanations would really help. Thanks.
In the end I achieved the desired effect with the code below, parsing a variable in to a page refresh, but this is only a work around.
var page = getUrlVars('page') || 0;
// Go time!!!
(function($) {
console.log('document ready');
buildPage(data[page]);
if(page == data.length - 1) {
page = 0;
} else {
page = parseInt(page) + 1;
}
setTimeout(function() {
window.location.href = 'index.html?page='+page;
}, 5000);
})(jQuery);