Skip to main content
100%

Gist 7657226

✓ Published0🌍 Public
Aalessioalex
Last edited Feb 22, 2013
Created on Nov 26, 2013

Cranium demonstrates a minimalist MVC implementation, showing how a model, view, and controller interact to update the DOM. The example uses Underscore.js for templating and utility functions, plus Cranium's own `Events`, `Model`, `View`, and `Controller` APIs. A counter model increments on button clicks, triggering the view to re-render its `<h1>` with the new value via `template` and `innerHTML`. A separate todo model demonstrates `set` and `get` with a checkbox, where a click event toggles completion and re-renders the view.

AI-generated description

Cranium is a minimalist MVC implementation I wrote to demonstrate how a developer might write their own MVC library within 20 minutes. The purpose of this exercise is to better appreciate what solutions like Backbone.js provide you out of the box.

You may use jQuery and Underscore (or lo-dash) for your implementation.

Note: This code is released strictly for educational purposes and should not be used in production. If you are searching for an MV* framework, TodoMVC.com may help with your selection process.

Similar vizzes