I have the next html page:
...
<script src="/Scripts/App/pep.js"></script>
</head>
<body>
<div id="main">
</div>
</body>
...
the 'pep.js' contains the next content:
var pep = {
models: {
},
views: {
loginView: Backbone.View.extend({
tagName: 'div',
id: 'loginContainer',
el: $('#main'),
events: {
},
initialize: function() {
this.listenTo(this.model, "change", this.render);
},
render: function () {
this.$el.html("<p>asd</p>");
return this;
}
})
},
route: Backbone.Router.extend({
routes: {
"login": "login", // #login
},
login: function () {
var lv = new pep.views.loginView;
lv.render();
}
}),
onReady: function () {
var r = new pep.route();
Backbone.history.start();
r.navigate('login');
}
};
$(pep.onReady());
Routing has working, but the view isn't rendered. Is there an error? The Backbone.js version is 1.2.3 The Chrome does not display any errors. Debugging allowed us to see that the browser enters the router and executes the method. However, the method does nothing.