Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Created November 7, 2012 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/4028709 to your computer and use it in GitHub Desktop.
Save cmilfont/4028709 to your computer and use it in GitHub Desktop.
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(){});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment