How can i get site users to leave a comment on a review left in a repeater?

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();
}

Hi Stevo,

We have a complete example of how to create a custom comments section here .

This example will show all the code you need to add to get your comments section working.

Hope this helps!

Dara | Corvid Team

Hi Dara, thanks for your swift reply, but would this work inside a repeater though? the main reviews that are left are tied to a repeater, i want people to be able to comment each individual review in a repeater. so there would be a comment button inside the main review within the repeater that gets clicked then a dropdown box becomes visible to input their comment, then once inputted another box appears underneath the review with the comment in, similar to how this works now on the wix forum thanks

“edit” also its not a blog

Thanks for sharing information I want to use it on site