Skip to content

Instantly share code, notes, and snippets.

@allouis
Created March 20, 2014 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allouis/9675312 to your computer and use it in GitHub Desktop.
Save allouis/9675312 to your computer and use it in GitHub Desktop.
Model View Controller Psuedoshite
var BookModel = Model.extend({
length: function () {
// take two for contents and index
return this.pages.length - 2;
}
});
var BookController = Controller.extend({
events: {
"click .save": "saveBook",
"change:saved": "render"
},
saveBook: function () {
this.model.saved = true;
},
render: function () {
this.view.render(this.model);
}
});
var BookView = View.extend({
template: "./views/book.hbs",
render: function (data) {
return mustache.render(this.template, data)
}
});
function createBook (data) {
var model = BookModel.create(data);
var view = BookModel.create();
var controller = BookController.create(model, view);
}
getBookViaAjax(function (data){
createBook(data);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment