I need help with nested Spacebars. So I have a helper below:
UI.registerHelper('scheduleDates', function (inc) {
var dateArray = [];
for (var i = 0; i < 7; i++) {
dateArray[i] ={
'dateValue': moment().day(i+7+inc).startOf('day'),
'formId': "formId"+i,
}
};
return dateArray;
});
It works fine when inc is set to 0. However, when it changes to 7 that’s when the dateValue starts skipping by month, and I can’t figure out why…
I have a drop down in my template. When that dropdown changes value, the value of inc changes based on a session variable. The value of inc can either be 0 or 7. Here is how my spacebars in my template look like:
I print out the value of inc and it correctly prints out 0 or 7 depending on what’s selected in the dropdown menu. According to the documentation on Spacebars, I don’t know why this doesn’t work and I could really use some help on figuring this out.
I don’t get any errors in this code. I just get the wrong output.
I added inc = parseInt(inc); and it now works. For whatever reason it though that int was a string rather than an integer. Is there a better way to do this?