Change your template to get rid of the outer div:
<div></div>
....
Then, tell the view to create the div with a class name:
tagName: "div",
className: "row"
OR if you want to keep the current template, then tell the View which el
to use (assuming it exists already some place on your page):
var testView = new TestView({el: $(".row")});
EDIT You asked if you can do this in the initializer? Sure, but you'd need to make sure that you hook the events:
initialize: function () {
this.el = $(".row");
this.delegateEvents();
_.bindAll(this, 'clickbtn');
}
Honestly, though, the first two options are more de-coupled IMO.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…