At the moment the documentation for $w.RatingsDisplay.rating states:
To reset the rating display element, restoring it to the empty state, set the value property to nullor undefined.
This element does not have a value property so you cannot reset the Ratings Display element to “no ratings” this way. The assumption would be that this text is referring to the rating property. If you try to assign undefined or null to the rating property a wix SDK warning is triggered stating the following:
I would suggest that if the
numRatings property is set to zero then there would be no ratings and so the element should be reset accordingly. It would be unusual for there to be any applied ratings if there were none on record
1 Like
Hi,
Thanks for taking the time to check this elements and comment. Wix users can use this elements for different purposes and in different ways. Therefor, this element has to support the flexibility to do what ever you want with it. For example, let’s say I want to collect ratings from site visitors and then to present those visitors the rating they provided. In this case, I need only ‘rating’ value and I don’t need ‘numRating’. The element also provides the ability to not show ‘numRatings’ value which is relevant for this case:

We cannot stick to one use case, even if it is the main one, and validate the element ‘rating’ value using ‘numRatings’.
You are right about your note changing the documentation from value to rating , we will do that.
I hope it answers your notes.
Let me know thoughts.
Idan
Hi Idan:
Understood. The use of the visual aspects of the element and the api are certainly related but connected. Showing the number of ratings in the UX shouldn’t rely on the value of the numRatings it should rely on a boolean that you can set to show or hide the number. Otherwise you are mixing two functionalities on the API to get one result which isn’t always a good practise and leads to ambiguity.
Further, if this is the expected behavior then the API needs to accept null or undefined as legitimate values without flagging a Wix API warning.
The dialogue you are showing above suggests that the API for the element should have two booleans that are aligned with the switches:
-
Show the Rating value ( true/false )
-
Show the number of ratings ( true/false )
Then
- use the ratings property to set the ratings value
- use the numRatings property to set the number of ratings.
This is simple, definitive and aligns well with the UI controls!
Cheers
Steve
I agree with your comment regarding removing the warning message and I agree that we should have boolean properties for show/hide the values in the UX. I will bring up for discussion both issues.
BTY, if you put this element on your site I will be glad to see your usage. You can post your site URL here or send it to me to idan.cohen@wix.com
TNX!