I'm trying to use ProgressBar.js in my Rails application, but I confess that I don't know much Javascript. I have this code in one of my views:
<div class="circleprogress" id="circleprogress"></div>
<script type="text/javascript">
window.onload = function onLoad() {
var circle = new ProgressBar.Circle('#circleprogress', {
color: '#38A6A6',
duration: 3000,
easing: 'easeInOut',
strokeWidth: 7,
trailColor: '#D5D5D5',
trailWidth: 1,
text: {
value: <%= (@percentage_of_goal * 100).round %> + '%'
},
});
circle.animate(<%= @percentage_of_goal%>);
};
</script>
And @percentage_of_goal
is already defined in my controller. The code works fine, but only after I refresh the page.
I've looked at other questions which seem to have the same problem, but the solution is to install the jquery-turbolinks
gem, and I've already done that and required it in my application.js, and it still only works after reload.
How do I fix this?