If you want to see a clear example of the problem I am facing, feel free to check out my sample application. Visit the site, click on a link to another page, then use your browser's back button to return to the previous page and navigate forward again. You'll hopefully understand what I'm trying to explain.
Here is the code for the previous page:
<h1>Form page</h1>
<div id="rating-form">
<label for="rating-form"> Rating </label>
</div>
I encountered an issue when loading my JavaScript code with this snippet:
$(document).ready(function(){});
The script didn't work as expected until the full page loaded. After reading up on it, I found this helpful solution:
$(document).on('turbolinks:load', function() {
$('#rating-form').raty({
path: '/assets/',
scoreName: 'review[rating]',
score: function(){
return 0
},
});
});
This implementation resulted in a bug within the sample application.
I tried using the gem 'jquery-turbolinks' based on this discussion, but unfortunately, it doesn't seem to work well with turbolinks 5.
If anyone has suggestions on how to resolve this issue, please let me know!