我试图弄清楚为什么会这样:
var TestView = Backbone.View.extend({
views: {},
initialize: function(){
this.bind('transistion:complete', this.onPageLoaded);
},
onPageLoaded: function(){
alert("works!");
}
});
var v = new TestView();
v.trigger('transition:complete');
但这不起作用:
var TestView = Backbone.View.extend({
views: {},
events:{
'transition:complete': 'onPageLoaded'
},
onPageLoaded: function(){
alert("works!");
}
});
var v = new TestView();
v.trigger('transition:complete');
能够从视图的事件对象中触发我的自定义事件会更整洁。无论如何我可以让它工作吗?