Im calling a for loop inside a for loop and its not working, here's the code :
function PopulateMonths() {
for (var m = 0; m < 12; m++) {
var $month = $('.d-month').clone();
$month.find('.d-header').text(m);
$month = PopulateDays($month);
$month.appendTo('#diary').show();
$month = null;
}
}
function PopulateDays($month) {
for (var d = 0; d < 30; d++) {
var $row = $('.d-row').clone();
$row.find('.d-day').text(d);
$row.appendTo($month).show();
$row = null;
}
return $month;
}
If I call PopulateDays manually 12 times it works fine, as soon as I try to loop 12 times using PopulateMonths() the page crashes, CPU usage goes through the roof so im assuming a lot of work is going on.
What am I missing?