doublesecretagency / craft-starratings

Star Ratings plugin for Craft CMS
Other
4 stars 3 forks source link

Have totalVotes update without page refresh #15

Closed AdamChlan closed 3 years ago

AdamChlan commented 3 years ago

We chatted on Discord about the fact that totalVotes does not update without a page refresh, and you suggested that I enter an issue on GitHub. I have a project in progress which I am hoping to leverage this on. Thank you!

lindseydiloreto commented 3 years ago

Thanks @AdamChlan!

What is your timeline? I may be able to work it into an upcoming release.

lindseydiloreto commented 3 years ago

Digging a little deeper... It looks like I may have been slightly confused about which plugin we were talking about. There is a totalVotes method in both Star Ratings and Upvote. The two plugins actually share a lot of DNA internally.

In Star Ratings, the totalVotes Twig method doesn't do anything except output a simple integer. The integer value isn't wrapped in any special HTML, so it's not really possible for me to control it via JavaScript.

I can, however, add a callback function to the JS rating event. So whenever an element is rated, your JS callback would be triggered. The callback function could then do whatever else you need in JavaScript.

Would that do the trick for you?

AdamChlan commented 3 years ago

Taking a look at Upvote, I'm wondering if that might be a good fit as well. Basically all I am looking for folks to do is cast a positive vote for multiple traits on an entry. And then have a tally of those votes. I also need custom icons, which looks like is supported. It would be great to have this available by end of February, if possible.

lindseydiloreto commented 3 years ago

If you're looking for a more binary system, then Upvote might be a better fit!

It sounds like we're both confused, so I'll just DM you on Discord until we sort it out. 😄