09 Apr 14
In this tutorial, I will show you how to make github embedded gists compatible with turbolinks.
As you may have noted following links on this site is a little bit faster if not faster than its normally is. I have achieved this with the help of Turbolinks gem. This means that I am able to get the bulk of the speed benefits but this comes at a cost as not everything will work as normal.
I ran into some problem trying to use Github embedded gists on this site. They din't work on pages loaded with turbolinks. I have to manually refresh a page to render the Github gists. This got me going crazy, searching every site on the internet looking for a solution. I finally got a solution from an issue raised on github about the same.
Though its not officially documented, I decided to write it here to act as a reminder for posterity. For those using coffee script simply include this snippet in your js.coffee file
For those using pure javascript, I converted the above coffee snippet to javascript
The last thing you now need to to is change all of your gist script tags into divs with a gist class and data attributes for the URL and the file name. Also, use the .json extension instead of .js. Like this:
And your good to go!! This site uses this solution to overcome this problem. Hope this helps someone. Have any comments? Feel free to leave one below.
Rails
20 Jun 18
In one of my recent projects, I was working on a scraper that needed to login into a website and download a file which I would then save to use later on. ...
Rails
05 Apr 15
Introduction It's been quite a while since my last tutorial and since then I've recieved alot of requests by email to implement a private messaging system ...
Ajax
22 Dec 14
With me, is a simple to-do list application where users can create dummy to-do lists and displays them in card-like form just like in Trello. We want to e...
Kenneth Kinyanjui
10 Apr 14
Insightful and useful.. Have not run into the issue but if I need to do I will stop by here
Victor Areba
25 Jul 15
Came in handy while integrating gists on my site. Thank you for this.