Skip to main content
100%

Gist 7f789f99d7069a4220ed

✓ Published0🌍 Public
Aamundo
Last edited Jul 18, 2014
Created on Mar 5, 2015

This example demonstrates a minimalist MVC architecture built with Cranium, a custom library that uses Underscore.js for utility functions and jQuery-like DOM selection. It shows how a model, view, and controller interact: user clicks on increment or alert buttons trigger controller methods, which update the model, and the view re-renders an Underscore template displaying the counter value. A separate todo example illustrates model changes notifying the view to re-render its checkbox and title template. The code relies on Cranium’s Events system for model-view communication and DOM event binding.

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