Hi Wix Gurus,
I’m hoping someone can help me figure out what’s going on here.
I have built out the Bookings Timetable from the tutorial and examples, and have it working. I’m able to book people for the correct dates (mostly). I just noticed a problem and I can’t figure out why this is happening. Let’s say today is 4/12, and the timetable shows the next six days in the daysToolbar repeater. When I click on Thu 4/15, and I look at the console.log, I get the following.
This is exactly what I expect. I see the date range from midnight to midnight of 4/15 midnight to 4/16 midnight. Nothing strange here.
Now, when I click ahead two weeks, and I land on the week showing 4/26 to 5/2, and I click on Fri 4/30, the console is printing the Set Active Day twice… once for the Fri previous (4/23), and once for the current Fri (4/30), like so…
Why is it setting the Active Day twice?
This becomes a major issue anytime I’m in a future or previous week because sometimes (not always), it logs the dates out of chronological order… like so (I’ve switched over to show the logs in Chrome)…
As you can see in the logs above, the log prints out the date I’ve clicked on (4/24) first, and then it prints out the previous Thu date (4/17). This is a problem because it has now set the slotRepeater to 4/17, even though the user believes they have clicked on 4/24.
When I go through and book this slot, it books the wrong day. It books 4/17, instead of 4/24 (which the user believes they are booking).
So, my main question is, and I can’t figure this out… why is it setting the Active Day twice (or three times if I’m three weeks in the future, or 4 times if I’m four weeks in the future)? The future and previous week buttons become unusable if it’s sometimes going to set the Active Day to the wrong date.
I’ve made some slight modifications to the original tutorial, but nothing that should be affecting how the Active Day is being set. Again, if we are in the current week, this is not a problem. Set Active Day gets set once to the correct date. This only becomes a problem when I click on the next week or previous week buttons and the code has to calculate the future or past date. For some reason, it’s printing out multiple Set Active Dates and I need it to only print out one date… the correct one.
Any help you can provide would be appreciated. Thanks.