ページに既にレンダリングされている HTML の一部のビューを作成しようとしています。ビューがインスタンス化されていることはわかりますが、どのイベントにもバインドできません。次に例を示します。
<html>
<head><!-- backbone, etc --></head>
<body>
<div id="myElement">
<button id="myButton">Click me</button>
</div>
<script>
new MyApp.Views.ExampleView()
</script>
</body>
</html>
私の見解(コーヒースクリプト):
class MyApp.Views.ExampleView extends Backbone.View
el: $('#myElement')
initialize: ->
console.log 'initialized'
events:
'click #myButton': 'alertMe'
alertMe: ->
alert('hello!')
私は何を間違っていますか?