window.APP = window.APP || {};
APP.crudRouter = Backbone.Router.extend({
routes: {
"crud/index": "index",
"crud/new": "create",
},
$container: $('#primary-content'),
initialize: function () {
this.collection = new APP.crudCollection();
this.collection.fetch({
async: false
});
$(document).ready(function() {
$('#list-cruds').DataTable();
} );
Backbone.history.start();
},
create: function () {
var view = new APP.crudNewView({
model: new APP.crudModel()
});
this.$container.html(view.render().el);
},
index: function () {
var view = new APP.crudIndexView({
collection: this.collection
});
this.$container.html(view.render().el);
$(document).ready(function() {
$('#list-cruds').DataTable();
} );
}
});