0
我正在尝试制作一个使用Backbone呈现用户身份验证视图的小应用程序。这里是一个小提琴演示http://jsfiddle.net/mjmitche/RRXnK/182/从其他视图中创建视图时不会呈现
初始化时,三个链接出现在div“span6认证”中,由AuthView放在那里。
<div class="span6 authentication">
<div class="row authentication">
<a href="#login" id="login" data-toggle="tab" data-content="login">Login</a>
<a href="#signup" id="signup" data-toggle="tab" data-content="signup">Sign up</a>
<a href="#retrieve-password" id="retrievePassword" data-toggle="tab" data-content="retrievePassword">Retrieve password</a>
</div>
<div class="content" id="auth-content">I want the sign up view to appear in this div if I click on the Sign Up link</div>
</div>
里有AuthView
events: {
'click .row.authentication a#login': 'login',
'click .row.authentication a#signup': 'signup',
'click .row.authentication a#retrievePassword': 'retrieve'
},
设置如果我点击注册,例如,(如小提琴)三个点击事件,它会创建RegistrationView并试图把在# auth-content div
signup: function(){
alert("from signup method of auth view");
var signUpView = new UserRegistrationView({model : this.model}).render().el;
alert(signUpView);
$('#auth-content').html(signUpView);
},
但是,它不起作用。正如你可以在小提琴中看到的那样,第二个提示没有被触发。这是注册视图。
var UserRegistrationView = Backbone.View.extend({
initialize:function() {
_.templateSettings = {
interpolate : /\{\{=(.+?)\}\}/g,
escape : /\{\{-(.+?)\}\}/g,
evaluate: /\{\{(.+?)\}\}/g
};
var template = $('#signup_template').html();
this.template = _.template(template);
},
render: function(){
alert("render of Registration View");
$(this.el).html(this.template());
}
})
任何人都可以指出什么问题可能与此设置。对于它的价值,JSHint说代码是有效的。