Hey guys,
Which is the correct way to use async await while assigning to rvalue
$w("#text6").text = await 'JJKJ';
or
await ($w("#text6").text = 'JJKJ');
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
Need help with add two reference items of other datasets to repeater save
here is the code, but it never save the reference values, any suggestions??
// For full API documentation, including code examples, visit https://wix.to/94BuAAs import wixData from 'wix-data'; let numSelected = 0; $w.onReady(async function () { var trpId; var resId ; $w("#TripDataSet").onReady( () => { let tripObj = $w("#TripDataSet").getCurrentItem(); // itemObj.title is the trip refernce value we need it for submition of trpId = tripObj._id ; } ); $w("#datasetResRead").onReady( () => { let itemObj = $w("#datasetResRead").getCurrentItem(); // itemObj.title is the trip refernce value we need it for submition of resId = itemObj._id ; } ); $w("#PaxAddDataset").onReady(async () => { if ($w("#PaxAddDataset").getTotalCount() === 0) { $w('#btnNewpax').disable(); await $w('#PaxAddDataset').new(); $w("#repeater2").onItemReady( ($item, itemData, index) => { let repeatedTrip = $item("#repeatedTrip"); let repeatedRes = $item("#repeatedRes"); repeatedTrip = trpId; repeatedRes = resId; }); } $w("#repeater2").onItemReady(($item, itemData, index) => { $item("#box2").style.backgroundColor = (index % 2 === 0) ? "#FAF0E6" : "#FFEFD5"; $item("#input1").onKeyPress((event) => { $w("#btnSavepax").enable(); $w("#btnNewpax").disable(); }); $item("#dropdown1").onChange((event) => { $w("#btnSavepax").enable(); $w("#btnNewpax").disable(); }); $item('#checkbox').onChange((event) => { let chk = $item('#checkbox').checked; if ($item('#checkbox').checked) { numSelected++; } else { numSelected--; } if (numSelected > 0) { $w('#btnDelete').enable(); } else { $w('#btnDelete').disable(); } }); }); }); }) export async function btnNewpax_click(event) { await $w('#PaxAddDataset').new(); let item = $w("#PaxAddDataset").getCurrentItem(); $w('#btnNewpax').disable(); $w("#repeater2").forEachItem(($item, itemData, index) => { $item("#box2").style.backgroundColor = (index % 2 === 0) ? "#FAF0E6" : "#FFEFD5"; if (item._id === itemData._id) { $item('#dropdown1').show(); $item('#input1').show(); $item("#txtName").hide(); $item("#txtState").hide(); } }); } export function btnSavepax_click(event, $w) { $w("#repeater2").forEachItem(async ($item, itemData, index) => { await $item("#PaxAddDataset").save(); }); $w("#txtSavedpax").show(); $w('#btnNewpax').enable(); } export async function btnDelete_click(event, $w) { $w("#repeater2").forEachItem(async ($item, itemData, index) => { if ($item('#checkbox').checked === true) { $item("#PaxAddDataset").remove(); } }); } export function repeater2_itemRemoved(_itemData) { $w("#repeater2").forEachItem(($item, itemData, index) => { $item("#box2").style.backgroundColor = (index % 2 === 0) ? "#FAF0E6" : "#FFEFD5"; }); $w("#btnNewpax").enable(); } // ------------------------------------------------------------
Of course you realize you don't need it for this case.
But if you are doing something like this:
let results = await GetStuff();
You use await for something you're waiting for. For more details, see async/await.