public
Created

  • Download Gist
djr.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
function DJR() {
 
this.ajax = function(params, success, url, method) {
$.ajax({
params:params,
success: success,
url: url,
type: method
})
};
 
for(var action in this.routes){
this[action] = function(params, success){
this.ajax(params, success, );
}
}
 
}
 
function CursosController(){ DJR.apply(this); }
 
CursosController.prototype.routes = {
index: {
url: "/cursos", method: "GET"
},
create: {
url: "/cursos", method: "POST"
},
destroy: {
url: "/cursos/:id", method: "DELETE"
}
}
 
var cursos = new CursosController
cursos.create({ nome: "Teste" }, function(){});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.