这是从我的网页查看的源代码:
<div id="webcontainer">
<div id="webheader"></div>
<div id="webbody">
<div id="webbodycontainer"></div>
</div>
<div id="webfooter"></div>
</div>
以下是观点:
var RegisterView = Backbone.View.extend({
el : $("#webbodycontainer"),
initialize : function(){
},
events : {
'click #register' : 'registerUser'
},
registerUser : function(){
alert("hi");
},
render : function(){
$("#webheader").html(headerTem);
$("#webfooter").html(footerTem);
var _registerDes = _.template(RegisterDescriptionTem);
this.$el.append(_registerDes);
}
});
return RegisterView;
_registerDes
内容显示在网页中,但不显示在DOM中,因此click
按钮上的#register
事件不会被触发。我错过了什么吗?
以下是RegisterDescriptionTem
模板:
<div class="registerleftpanel">
//....
</div>
<div id="rightpanel" style="float:right; padding-right:10px;">
<div id="registerPanel" style="width: 528px;">
<div class="cartheadertitle loginheadertitle">Register New Account</div>
<br>
<form id="registerForm" style="margin-bottom: 10px;">
//......
<div style="position: relative; float: left; left: 90px; top: -3px;">
<input type="button" value="Register" class="btn" id="register">
</div>
</form>
</div>
</div>