I've asked another question yesterday about issues with javascript. I have gem 'jquery-turbolinks', '~> 0.2.1' installed.
The problem is that the rating for post is not showing(displaying stars). It worked fine few days ago, but now it's just not displaying stars.
ratings.coffee
ready = ->
$("form[data-update-target]").bind "ajax:success", (evt, data) ->
target = $(this).data("update-target")
$("#" + target).prepend data
$('#content').val('')
$('.rating-total').each () ->
score = $(this).data('score')
$(this).raty({
haftShow: true,
score: score,
readOnly: true
})
$(document).ready(ready)
$(document).on('page:load', ready)
file for displaying stars
<div class="rating-total" data-id= <%= post.id %> data-score= <%= avg_score_for(post) %> >
</div>
<div class="total-score">
<%= avg_score_for post %>
</div>
html output
<div class="rating-total" data-id= "1" data-score= "3.0" >
</div>
<div class="total-score">
3.0
</div>
Do you insert or update the star container via ajax (aside turbolinks)? Then you would need to initialize raty on this which you now only do on page load.
We render the stars directly and update the score and vote count like this:
Our controller just returns a json with rating and vote count.