fd Blog

Daniel Hilgarth on software development

Fixing Octopress’ GitHub Plugin When Using jQuery

A quick one:

After adding the functionality of automatic syntax highlighting and jQuery in the process, I noticed that the GitHub plugin was no longer showing my repositories. It got stuck on “Status updating…”.

A quick look in the JavaScript console showed that $.domReady - used by source/_includes/asides/github.html - was no longer defined. I guess jQuery overrode the methods defined by Ender.js.

The fix was quick: Use $(document).ready instead.

But that just brought about another error:

XMLHttpRequest cannot load https://api.github.com/users/dhilgarth/repos?sort=pushed&callback=?. Method JSONP is not allowed by Access-Control-Allow-Methods.

It turns out that jQuery’s ajax method doesn’t understand type: 'jsonp' - it has to be dataType: 'jsonp' instead. After chaning this in the showRepos method defined in javascript/github.js the GitHub plugin finally started working again!

Comments