ruby-on-rails-4turbolinkscufon

cufon fonts do not work on all my pages


I have a problem with my page: on start page cufon-yui is loaded fine, but when I go to another page, it doesn't load. But when I refresh, it looks fine. I use turbolinks.

application.html.erb

application.js


Solution

  • Turbolinks works by replacing the page content instead of navigating to a new page. If you're calling cufon-yui on document.ready, then it will NOT be called when you navigate to a new page. Your code should then look like:

    $(document).on 'ready page:load', function(event)
    {
      Cufon.replace("whatever you're replacing");
      // And whatever other Cufon code you're using is.
    }
    

    This way, it'll be called both when the document is ready, as well as when page:load is called by Turbolinks upon the completion of the page loading process.