I'm having trouble passing an event from jQuery to JavaScript. I am setting the JS event listener first and then firing the jQuery event from an external file, but the listener never gets triggered. Here's some code:
Listener
<script type="text/javascript">
document.addEventListener('readyToPlay', loadLibs);
function loadLibs() {
alert('success');
}
</script>
<script src="/assets/js/plugins/co/co.js" type="text/javascript"></script>
Included File - The alert returns (function), which means jQuery is loaded
function init() {
alert(typeof jQuery);
$(document).trigger('readyToPlay');
}
I am thinking the issue might be caused by referencing document in the external file, but I'm not sure how to get around that.