嗨,我对backbone.js很新,我只想弄清楚它是如何工作的。我正在使用bootstrap for UI和backbone.js来添加功能。但是,以下骨干视图未显示任何内容。如果我在任何地方都错了,请纠正我。
<script type="text/template" id="login-template">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">SwipteIt</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control" id="LoginEmail">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control" id="LoginPassword">
</div>
<button type="submit" class="btn btn-success" id="loginButton" >Sign in</button>
<div class="form-group">
<a href="signup.html"><span class="glyphicon glyphicon-user"></span> Sign Up</a>
</div>
</form>
</div><!--/.navbar-collapse -->
</div>
</nav>
</script>
var LogInView = Backbone.View.extend({
events: {
"click #loginButton": "logIn",
// "submit form.signup-form": "signUp"
},
el: ".content",
initialize: function() {
_.bindAll(this, "logIn");
this.render();
},
logIn: function(e) {
alert("hello world");
// return false;
},
render: function() {
this.$el.html(_.template($("#login-template").html()));
}
});
new LogInView();