Wrap your function in $(document).ready(function() { })
, or more simply, $(function() {
. In CoffeeScript, this would look like
$ ->
$('#myModal').on 'show.bs.modal', (event)->
Without it, the JavaScript is executing before the document loads, and #myModal
is not part of the DOM yet. Here is the Bootstrap reference.