Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active August 29, 2015 14:01
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/ab77c54945c4b8eedb63 to your computer and use it in GitHub Desktop.
Save cmilfont/ab77c54945c4b8eedb63 to your computer and use it in GitHub Desktop.
App = { fields: {}, field: {} };
App.field.Field = function(){
this.callSuper = function(args){
var name = arguments.callee.caller.$name;
var parent = new this.parent;
parent[name].apply(this, args);
};
this.render = function(json){
console.log("Field", json);
};
this.$constructor = function() {
var instance = this;
for(var name in instance) {
var fn = instance[name];
if( typeof fn === 'function') {
fn.$name = name;
}
}
}
}
App.field.Text = (function(){
var klass = function() {
this.$type = "textfield";
this.parent = App.field.Field;
this.parent();
this.render = function(json){
console.log("Before", json.name);
this.callSuper(arguments);
console.log("After", json.name);
};
this.$constructor();
};
App.fields["textfield"] = klass;
return klass;
})();
field = new App.fields["textfield"]();
field.render({ name: "Adalto" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment