beyond-z/beyondz-platform — pull request #73 by adamdruppe (2014-06-09 14:55:05+00:00)
Title: Video play problem on next button fixed

This was a fairly tricky one, see: http://stackoverflow.com/questions/20749622/jquery-ujs-has-already-been-loaded-rails and http://stackoverflow.com/questions/22838515/loading-javascript-with-turbolink-plugin which have similar problems (though their specific fixes didn't work since they didn't include the youtube api).

The comment in the code explains what is going on. In short, the turbolink plugin causes API ready events to not always be triggered, so we track that with a global variable ourselves and call it when needed.