Hi there,
Having an absolute nightmare building a repeater without a database. Here is my code:
I define the initial repeater data in the $w.onReady function, as seen below:
$w.onReady(function () {
//TODO: write your page related code here...
let tutorName = session.getItem("tutorName");
console.log("i: " + i.toString())
console.log("tutorName: " + tutorName)
if (tutorName !== undefined) {
initItemData = [
{
"_id": i.toString(),
"bookingTitle": "Booking " + i.toString() + ":",
"who": tutorName,
"service": "Private Tutoring"
}
];
}
else {
initItemData = [
{
"_id": i.toString(),
"bookingTitle": "Booking " + i.toString() + ":"
}
];
}
display_bookings(initItemData);
});
I then pass this data to a display_bookings function and this is where the issue begins:
Inside the first ‘if’ statement I set the value of the dropdown and the placeholder to be itemData.who. The placeholder works but the value setting doesn’t… see console output below code snippet!
function display_bookings(Data){
$w('#bookingRepeater').data = Data;
$w('#bookingRepeater').onItemReady(($item, itemData, index) => {
console.log("data fed: " + Data[index])
if (itemData.who !== undefined) {
$item('#who').placeholder = itemData.who;
$item('#who').value = itemData.who;
console.log("I SET THE VALUE: " + $item('#who').value)
console.log("I SET THE PLACEHOLDER: " + $item('#who').placeholder)
}
if (itemData.bookingTitle !== undefined) {
console.log("I SET THE TTTLE")
$item('#bookingTitle').text = itemData.bookingTitle;
}
if (itemData.date !== undefined){
// work out how to store and set dates
//$item('#date').
}
if (itemData.time !== undefined){
// work out how to store and set times
//$item('#date').
}
if (itemData.service !== undefined){
// work out how to store and set dates
$item('#service').value = itemData.service;
$item('#service').placeholder = itemData.service;
}
if (itemData.repeatOption !== undefined){
// work out how to store and set dates
$item('#repeatOption').value = itemData.repeatOption;
$item('#repeatOption').placeholder = itemData.repeatOption;
}
update_summary($item, itemData, index);
})
}
Why is this?
I’m having other issues but I think they will serve better as a separate post
Cheers in advance!