Search...
onCommentCountChange( )
Adds an event handler that runs when a comment is added or removed from the WixComments
element.
Description
The onCommentCountChange()
function adds an event handler that runs when a comment is added or removed from the WixComments
element.
Syntax
function onCommentCountChange(callback: OnCommentCountChangeCallback): Promise<void>callback: function OnCommentCountChangeCallback(count: number): void
onCommentCountChange Parameters
NAME
TYPE
DESCRIPTION
callback
The callback function that runs when a comment is added or removed from the WixComments
element.
Returns
Return Type:
Promise<void>
OnCommentCountChangeCallback Parameters
NAME
TYPE
DESCRIPTION
count
number
The current comment count in the WixComments
element.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
Add an event handler for counting comments in the comment widget
Copy Code
1$w("#myCommentsWidget").onCommentCountChange( (count) => {2 console.log(`Comments count: ${count}`);3});
Add an event handler to display the comment count in a text element
Copy Code
1$w("#myCommentsWidget").onCommentCountChange((count) => {2 $w('#myText').text = `Total Comments: ${count}`;3});