If you started using FontAwesome-5 in a Turbolinks project, you will quickly notice the icons disappear after the first page reload. So how can we fix that? I did not immediately find a reference inside the FontAwesome documentation, but luckily google proved helpful and I found this issue
Inside the issue I found the fix which I applied and worked for me. I created a new file app/javascripts/fix_fontawesome_reload.js
with the following content
document.addEventListener("turbolinks:before-render", function(event) {
FontAwesome.dom.i2svg({
node: event.data.newBody
});
});
which was then automatically included in application.js
(because I have the require_tree
line).
Comments
Add comment