Hey Velo Team, I would really appreciate some help in the situation I am in.
I have coded a button called Add Dog
that creates new repeater items (max up to 3)
There is an Order Now button that has a click event. On Click, I want to be able to make sure all the required and displayed dropdowns are filled, if they are not filled, then it displays a warning message. Once it checks all the required dropdowns are filled, it then takes all the values from the displayed dropdowns and adds them to the database.
When I coded the check to see if dropdown values are empty, it never updates if a dropdown has been changed and therefore always displays the warning text. I am currently new to Wix repeaters so I also do not know how to iterate through its list and extract all the information and update them to the database. My code is shown below.
// Tilapia + Polenta - Adding a dog
export function tpAddDog_click(event) {
let data = $w('#tpAddDogRepeater').data;
let length = $w('#tpAddDogRepeater').data.length;
let newId = Number(length + 1);
let newlet = {
_id: `item${newId}`
};
data.push(newlet);
$w('#tpAddDogRepeater').data = data;
if (length === 2) {
$w('#tpAddDog').hide();
}
}
// Tilapia + Polenta - Deleting a dog
export async function tpDeleteDog_click(event) {
let data = $w('#tpAddDogRepeater').data;
await data.pop();
$w('#tpAddDogRepeater').data = data;
$w('#tpAddDog').show();
}
// Tilapia + Polenta
// Check Missing Fields
export function tpOrderNowBtn_click(event) {
if ($w('#tpDogSize').value === '') {
$w('#tpWarningText').show();
} else {
$w('#tpOrderNowBtn').label = 'Please Wait';
$w('#tpWarningText').hide();
}
}
I would really appreciate any guidance on this workflow. The reason I have a Repeater for this is because, with the Add Dog button, I want to be able to add maximum 2 new fields after which it hides.