我正在尝试学习Marionette.js
。我从这个链接开始。而 viewobject 作为参数传递给 Regionobj。收到以下错误。
Uncaught TypeError: Object [object Object] has no method 'listenTo'
HTML 代码:
<script src="lib/jquery-1.8.3.min.js"></script>
<script src="lib/underscore-min.js"></script>
<script src="lib/backbone-min.js"></script>
<script src="lib/handlebars.js"></script>
<script src="lib/backbone.marionette.js"></script>
<div id="firstDiv">
<input id="firstButton" type="button" style="width:100px;height:50px;color:white;background-color:red;" value="Click Me!">
</div>
js代码
var myView=Backbone.Marionette.ItemView.extend({
events:{
"click #firstButton":"alertFunction"
},
alertFunction:function(){
alert("Hi");
console.log(this.el);
}
});
var myViewObj=new myView();
var myRegion = new Backbone.Marionette.Region({
el: "#firstDiv"
});
myRegion.show(myViewObj);
我怎样才能解决这个问题。