When my page loads for the first time the code in /assets/javascript/home.js executes, which positions my navbar using Bootstraps affix.
$('.navbar').affix({
offset: {
top: function() {
return this.bottom = $('.hero').outerHeight(true);
}
}
});
When I go to another route such as /blog
, I don't want this code to execute and want my static CSS to render which works great. The problem is when I got back to the home route(/
), the JavaScript doesn't execute again and my navbar is using its natural CSS. If I refresh at this point, the page will reload fully and my navbar will be positioned correctly.
I think the problem is because of turbo-links but I am not experienced enough with Rails to resolve this issue. Hope somebody can shed some light!