Vorbly <Code>
CODING MADE EASY WITH VORBLY
WIX REPEATERS LIKE BUTTONS FOR COMMENTS
Need a "like" button and counter for your comments section? This tutorial will show you how to customize your comments section with a "like" button and counter using Wix Repeater. We will provide you with the webpage elements and sample codes required to implement this feature.
THE DEMO
THE ELEMENTS
The Page
Repeater: #repeater1
-
Name: #name
-
Comments: #comments
-
Date / Time Text: #date
-
Like Button: #Like
-
Like Counter: #counter
The Database
Create a database: Comments (dataset1)
-
Name: name
-
Comments: comments
-
Like Count: like
-
Date / Time: _createdDate
β
Then link fields to your repeater. For this example, we use Like (like) for the like counter in the repeater.
THE CODE
Page Code
export function Like_click(event, $w) {
let like = Number($w('#dataset1').getCurrentItem().like);
let CurrentItem = $w('#dataset1').getCurrentItem();
β
let toUpdate = {
"_id" : CurrentItem._id,
"name" : CurrentItem.name,
"comments" : CurrentItem.comments,
"like" : Number($w('#counter').text)
};
β
$w('#counter').text = String(like +1);
$w('#Like').disable();
β
wixData.update("Comments", toUpdate);
}
COMMENTS
I'm a paragraph. Click here to add your own text and edit me. It's easy.