Search code examples
ruby-on-railsfont-awesometurbolinks

Font Awesome icons not rendering on dynamically rendered partial


I have a partial in Rails that gets rendered after a remote put request via the update.js.erb.

The problem was the element, which is supposed to have font-awesome icons, is not rendering the actual icons. It has the classes but not showing the icons.

The icons appear if I refresh the page, also if I disable turbolinks for that page. But I don't want to disable turbolinks.

Any help?


Solution

  • Actually I just found a solution. We just need to run the following code after the turbolinks:load event:

    FontAwesome.dom.i2svg()
    

    I found the solution here: https://www.nicholasshirley.com/using-font-awesome-5-and-the-rails-asset-pipeline/