I am trying to create a view for a piece of HTML that has already rendered on the page. I can see that the view is being instantiated, but I can't bind to any events. Here is an example:
<html>
<head><!-- backbone, etc --></head>
<body>
<div id="myElement">
<button id="myButton">Click me</button>
</div>
<script>
new MyApp.Views.ExampleView()
</script>
</body>
</html>
My View (coffeescript):
class MyApp.Views.ExampleView extends Backbone.View
el: $('#myElement')
initialize: ->
console.log 'initialized'
events:
'click #myButton': 'alertMe'
alertMe: ->
alert('hello!')
What am I doing wrong?