2
아래 코드를 작동시키는 데 문제가 발생했습니다.Backbone.js보기 안의보기에서 이벤트 실행
고유 한 이벤트 객체가있는 렌더링 된 하위보기에서 이벤트를 실행하려고합니다.
쉬운 방법으로이 작업을 수행 할 수 있습니까?
var SubView = Backbone.View.extend({
events: {
'click .subview-item a': 'test'
},
el: '#subview',
test: function() {
console.log('please print this...');
},
initialize: function() {
this.template = '<div class="subview-item"><a href="#">Clickable Subview</a></div>'
},
render: function(){
$(this.el).html(_.template(this.template));
return this;
}
});
var MainView = Backbone.View.extend({
el: $('#content'),
initialize: function(){
this.template = '<h1>Hello</h1><div id="subview"></div>';
this.subView = new SubView();
},
render: function(){
$(this.el).html(_.template(this.template));
this.subView.render();
return this;
}
});
var mainView = new MainView({});
mainView.render();
어떤 아이디어 ??