Info
Features
Prototype, jQuery, Dojo, YUI, Ext, MochiKit, Open Rico, Moo Tools, etc
More Code == More problemsDevelopers need to confront the same problems
of any large software project.
Common problems:
JavaScriptMVC attacks these problems with best practices.
| Quality | Dev. Time | Maintainability |
|---|---|---|
| Test | Fixtures | Include |
| Easy Update | Code Generators | File structure |
| Error Reporting | Scaffolding | Model |
| Plugins and Engines | View | |
| Controller | ||
| MVCDoc |
Provides:
Automatically update to the latest code.
js jmvc\update
javascript error reporting
Features
substitute ajax responses
Use for:
//generate a fixture js jmvc/generate/fixture get todos.json
//contents of /test/fixtures/todos.json.get
[{attributes: {id: 1, name: "take out trash"}}]
Quickly create code in the right place.
//creates a new app js jmvc\generate\app APPNAME //creates an html page js jmvc\generate\page PAGE_LOCATION //creates a controller js jmvc\generate\controller CONTROLLER //creates a model js jmvc\generate\model MODEL_TYPE MODEL
Get basic CRUD functionlity off the ground, expand from there.
Install 3rd party code and dependencies from command line.
| Splitter | Fixed box | Slider |
|---|---|---|
| Sortable | Modal | Tabs |
Maintainable code is ...
loads and compresses JS files
Use
include('file1','../folder/file3',
function(){ ... })
Compress
js apps\APP_NAME\compress.js
standard file structure
simulated class object
Monster = Class.extend("monster",{},{})
SeaMonster = Monster.extend("sea_monster")
What's in JS app?
Wraps data layer
Wraps app's data layer in 2 ways:
Features:
Example
Todo = JsonRestModel('todo',{
days_remaining: function(){
return (this.date - new Date()) /
(1000*60*60*24);
}
})
Todo.find('all', function(todos){
for(var i = 0; i < todos.length; i++)
alert(todos.days_remaining());
})
JS templating library
Features:
Example:
<h1><%= title %></h1>
Responds to events
Features:
HTML
<div class='todo todo_5'>
<input class='complete' type='checkbox'/>
<div class='handle'></div>
</div>