Skip to content

Instantly share code, notes, and snippets.

@jupiterjs
Created December 7, 2010 23:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jupiterjs/732612 to your computer and use it in GitHub Desktop.
Save jupiterjs/732612 to your computer and use it in GitHub Desktop.
Can your framework do this?
//- CONTROLLER -
$.Controller("Tabs",{
"li click" : function(){
}
})
// will automatically create a jQuery plugin like:
$('#mytabs').tabs()
/*
When this tab widget is crated, it automatically delegates
all event handlers that look like "li click".
It adds the instance of the plugin to jQuery.data for easy debugging.
It adds a 'tabs' className to #mytabs for easy debugging.
You can completely teardown the plugin (and event handlers) like:
*/
$('#mytabs').tabs("destroy")
// Controller is essentially the perfect plugin:
// http://jupiterjs.com/news/writing-the-perfect-jquery-plugin
//- MODEL -
$.Model('Todo',{
findAll : '/todos.json'
attributes : {
dueDate : 'date'
}
},{
prettyDate : function(){
return (this.dueDate > new Date() ? "the future" : "the past")
}
})
// The following will go to /todos.json, convert dueDate to a JS date and
// wrap each todo with the prettyDate helper function:
Todo.findAll({}, function(recipes){
alert('the first recipe is in '+recipes[0])
})
/**
You can add to model,
Lists
Validations
Associations
Backup / Restore
Client side storage
Property binding
*/
//- VIEW -
// call templates like:
$("#content").html('//path/to/template.ejs',{ });
// packaged the processed template with your production script like:
steal.views('//path/to/template.ejs')
/***
These are just a tiny fraction of the good stuff in just the MVC parts.
I could go on about the features: http://jupiterjs.com/news/javascriptmvc-features
but no one likes smug ;-). But a few follow up qs
*/
// How do you automate tests?
// How do you package a build?
// How do you document?
/**
I don't know how someone could call JavaScriptMVC overkill if they are building
reasonably complex applications. It makes everything you should be doing
a lot easier. Let me know what you think. I love feedback.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment