Please help - this is driving me nuts.
I have a repeater in a dynamic page. I am trying to change the date format of an element in this repeater, pulling the original data from a database. I DO have the database connected to the overall repeater, but DO NOT have a field directly connected to the text element that I want to display the date. It works fine when I try it in preview. But when it’s live, when a page loads, it will flash with the correct formatted date, then change to the template text of the repeater. The developer console is not flagging anything.
Here is the code:
$w.onReady( function () {
// FIELD TWO
$w(“#repeater1”).onItemReady(($w, itemData, index) => {
const monthNames = [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”];
console.log(itemData.startDate);
console.log(itemData.startDate.getDate().toString());
console.log(monthNames[itemData.startDate.getMonth()]);
console.log(itemData.startDate.getFullYear().toString());
console.log(itemData.startDate.getHours().toString());
console.log(itemData.startDate.getMinutes().toString());
const strDate = itemData.startDate.getDate().toString();
const strMonth = monthNames[itemData.startDate.getMonth()];
const strYear = itemData.startDate.getFullYear().toString();
const strHour = (“0” + itemData.startDate.getHours().toString()).slice(-2);
const strMinute = (“0” + itemData.startDate.getMinutes().toString()).slice(-2);
$w("#text1").text = "Start: " + strMonth + " " + strDate + ", " + strYear + " " + strHour + ":" + strMinute;
});
});
I am not a developer and would appreciate anyone’s insights into what’s going on there. Many thanks!!!