Trying to build an RSVP type system.
Elements
#userinput1
#button1
#dataset1 (passcode(text), guestname(text), rsvp(bool),mealpref(text)
#repeater1 (hidden by default)
#guestnametext (text - #dataset1/guestnametext)
#rsvpcheckbox (user input - checkbox - #dataset1/rsvp)
#mealpref (user input - selection - #dataset1/mealpref)
#rsvpbutton (user input - #dataset1/submit)
Functionality:
(Good) User navigates to RSVP page. Presented with textbox (#userinput1), and #button1.
(Good)Places in passcode and hits #button1. Filter applied to #dataset1. Show #repeater1.
(Somewhat working, and acceptable) If #rsvpcheckbox is checked, show #mealpref. If #rsvpcheckbox is not checked hide #mealpref.
Problem - if #rsvpcheckbox is unchecked from being checked, then the #mealpref is NOT hidden
(Not working) #rsvpbutton button should save user input in ALL repeated items.
Problem - when using a submit button it only saves input from the first item in the repeater.
import wixData from ‘wix-data’;
$w.onReady( function () {
//TODO: write your page related code here…
$w(‘#dataset1’).onReady(() => {
$w(“#repeater1”).forEachItem( ($item, itemData, index) => {
if ($item(‘#rsvpcheckbox’).checked) {
$item(“#mealpref”).show();
} else {
$item(“#mealpref”).hide();
}
} );
$w(“#rsvpcheckbox”).onChange( (event, $w) => {
let $item = $w.at(event.context)
if ($item(‘#rsvpcheckbox’).checked) {
$item(“#mealpref”).show();
} if (!($item(“#rsvpcheckbox”))) {
$item(“mealpref”).hide();
}
});
});
});
export function button1_click(event) {
//Filter the database based on the user input
//Filtering should match the user input (provided personal passcode), and display all guests with same password in repeater
$w(‘#dataset1’).setFilter(wixData.filter().eq(‘passcode’, $w(‘#input1’).value));
setTimeout(() => {
$w(‘#guestrepeater1’).show();
$w(‘#rsvp’).show();
}, 500);
}