The following is a quick overview of what's going on with JMVC since 3.0:
$('#recipes').html('recipes.tmpl', Recipe.findAll() );
Classes are used to simplify JavaScript constructor creation. Both $.Controller and $.Model extend $.Class.
To create a Class class of your own, call $.Class.extend with the:
You need a client-side dependency management and build system. What I mean by this is:
A client-side script loader that does dependency management and can package your scripts for rapid download.
There are only 2 that I'm aware of that qualify are RequireJS and StealJS. There are 3 reason to use these systems:
(function(){ | |
var my$ = function(selector){ | |
if(!(this instanceof my$)){ | |
return new my$(selector); | |
} | |
if(typeof selector === 'string'){ | |
var arrayOfElements = my$.makeArray( document.querySelectorAll(selector) ); |
steal('jquery/model', | |
'jquery/dom/fixture', | |
'jquery/view/ejs', | |
'jquery/controller/route',function(){ | |
$.fixture("GET /services/todos.json", function(){ | |
return [200,"success",[ | |
{id: 1, | |
name: "wake up"}, |
$.fixture("/searchresults", function(options){ | |
var countries = [{ | |
id: 1, | |
name : "Apple" | |
}] | |
if(!options.data.q){ | |
return [countries]; | |
} |
steal('jquery/controller', 'jquery/model', function() { | |
$.Model("Paginator", { | |
defaults: { | |
limit: 100, | |
offset: 0, | |
count: Infinity | |
} | |
}, { |
(function(){ | |
var set = function(obj, prop, val){ | |
Object.defineProperty(obj,prop,{ | |
value : val | |
}) | |
return val; | |
}; |
There's so many things wrong with the world of script loading today. I want an easy way to:
I want it to: