0

I have a question regarding jQuery Raty plugin.

I have a page that lists posts for cars where every post has ratings 1-5. When I go to a specific car post and the go back to the page that show all cars posts using Back arrow in Chrome navigation then the stars gets duplicated. So from 5 stars i get 10 stars.

My code in the car comments index:

    $('.review-rating').raty({
      readOnly: true,
      score: function() {
        return $(this).attr('data-score');
      },
      path: '/assets/'
    });

Any tips here?

Thank you i advanced.

Webbie
  • 537
  • 2
  • 10
  • 25

1 Answers1

0

you can reload to avoid this and perhaps don't forget the preventDefault, and stopPropagation as well. But to avoid the duplication of stars try this $('.review-rating').raty('reload');

//e.stopPropagation();
//e.preventDefault();
$('.review-rating').raty({
  readOnly: true,
  score: function() {
    return $(this).attr('data-score');
  },
  path: '/assets/'
});
$('.review-rating').raty('reload');
Elias Glyptis
  • 470
  • 5
  • 9