i am a beginner in in programing so bear with me please
this is a repeater , with 4 inputs should carry and view data from collection called visits
i did view visits data in a input so that i can change the values of a certain field, and there is a button to trigger the changes.
but i am so stupid and have no knowledge but i am trying my best to learn.
this is my code i know its a very ugly and stupid code , but really can use some help because it does not work ðŸ˜
export function repeater1_itemReady($W, itemData, index) {
$w('#button3').onClick(() => {
console.log('1 pass')
const item = itemData
const h = item._id
console.log(h)
itemData.detail = $w('#textBox1').value
itemData.quadrant = $w('#input4').value
itemData.premeasure = $w('#input3').value
itemData.toothnumber = $w('#input2').value
let toUpdate = {
"_id": h,
"date": "Mr.",
"detail": $w('#textBox1').value,
"quadrant": $w('#input4').value,
"premeasure": $w('#input3').value,
"toothnumber": $w('#input2').value
};
wixData.update("visits", toUpdate)
.then((results) => {
let item = results; //see item below
})
.catch((err) => {
let errorMsg = err;
});
})
Try this one.... (not tested)....
import wixData from 'wix-data'; $w.onReady(function () { $w('#repeater1').onItemReady(($item, itemData, index)=>{ $w('#button3').onClick(()=> {console.log('1 pass'); itemData.detail = $item('#textBox1').value itemData.quadrant = $item('#input4').value itemData.premeasure = $item('#input3').value itemData.toothnumber = $item('#input2').value let toUpdate = { "_id": itemData._id, "date": "Mr.", "detail": $item('#textBox1').value, "quadrant": $item('#input4').value, "premeasure": $item('#input3').value, "toothnumber": $item('#input2').value }; wixData.update("visits", toUpdate) .then((results) => {let items = results; console.log(items);}) .catch((err)=>{let errorMsg = err;}); }); }); });
Else you would have a second option to use forEachItem....
https://www.wix.com/velo/reference/$w/repeater/foreachitem