hey as above i’m having trouble coding the repeater for comments left on a review thats left in a repeater like this
this is the code i’ve implemented but it doesn’t work
$w.onReady(function () {
//place a post comment button on the page and call it commentButton1
$w("#reviewsRepeater").forEachItem(($item, itemData, index) => {
$w('#commentButton1').onClick(function () {
$w('#commentBox').expand();
//dataset1 is connected to your collection where you store the original post
let orininalPostId = $item("#Reviews").getCurrentItem()._id;
let currentUserEmail = $w('#commentEmail').value;
let comment = $w('#commentInputBox1').value;
//dataset2 is connected to your collection where you store the comments, make sure you have set read/write access to dataset2
$w("#dataset2").onReady(() => {
/*
let user = wixUsers.currentUser;
//get userEmail so that it can be passed to the comments database that way we know who made the comment
user.getEmail()
.then((email) => {
*/
//create columns in your comments database and name them orininalPostId, comment, userEmail. Place an comment input box on the page and call it commentInputBox1
//now we save the comment to the database
let toSave = {
"orininalPostId": orininalPostId,
"comment": comment,
"userEmail": currentUserEmail,
};
let options = {
"suppressAuth": true,
"suppressHooks": true
};
wixData.save("comments", toSave, options)
.then((results) => {
let item = results; //see item below
})
.catch((err) => {
let errorMsg = err;
});
})
})
})
})
export function cancel_click(event) {
$w('#commentBox').collapse();
$w('#commentBox2').collapse();
}
export function commentButton_click(event) {
$w('#commentBox2').expand();
}