Comments in Repeaters

Hi Guys,
I need your advice - how can i add comments functions to my repeaters ?
I’ve tried to add disqus but in this case comment for one my item replicated to all other and that’s differently what i’m looking for. I wont to have a separate comment trad for each item.

Thank you in advance ^ ^

Hi Terry,

Welcome to WixCode, where amazing things happen.

I’m not exactly sure what the problem is. Why not just add a text input field to the repeater item? This will then be applied to only that repeater item.

If I missed the point let me know what it is your’re trying to accomplish.

Yisrael

I’m also interested.
I think what Terry means is that with Wix default comment apps (Comments …) all comments are shown on each item page.

Maybe there is a way to build our own comment box with repeaters / code, but how ?

Hello all,
About the question, comment in repeater.
I guess you want to let web user can comment on repeater card ?

@Henson Li - I would love to be able to do that. I have built a newsfeed using repeaters, and would love for users to add comments on each repeater

bump

import wixUsers from “wix-users”;

$w.onReady(function () {

//place a post comment button on the page and call it commentButton1 

$w('#commentButton1').onClick(function () { 

    //dataset1 is connected to your collection where you store the original post 

    let orininalPostId = $item("#dataset1").getCurrentItem()._id; 

    //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) => { 
                let currentUserEmail = 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 

                $w('#dataset2').setFieldValue('orininalPostId', (orininalPostId)); 
                $w('#dataset2').setFieldValue('comment', $w('#commentInputBox1').value); 
                $w('#dataset2').setFieldValue('userEmail', (currentUserEmail)); 
                $w('#dataset2').save() 

            }) 
    }) 
}) 

})

1 Like

hey mike,

firstly you area legend!

if the users first name was in a third database, how would you tweak the above code?

big mike?

If you add a text input field to the repeater of course you add a comment there , but it gets repeated in all items in the dynamic page, how to solve it?

Hi Tristan, did you solve this problem, getting crazy, thank you

I have entered a wix code and received this ReferenceError: Can’t find variable: $item