var Item = Class.create(); Item.prototype = { initialize: function( oArgs ) { this.Parse( oArgs ); }, Class: "Item", Fetch: function( id ) { var cmd = {}; cmd.cmd = this.Class + "::View"; cmd.id = id; var self = this; $.post( ASettings.APIPATH, cmd, function( response, code ) { response = eval( '(' + response + ')' ); self.Parse( response ); } ); }, // OVERLOADED BY CHILDREN CLASSES ... Parse: function( data ) {}, Delete: function() { var cmd = {}; cmd.cmd = this.Class + "::Delete"; if( !parseInt( this.Attributes.id ) ) { return false; } cmd.id = this.Attributes.id; $.post( ASettings.APIPATH, cmd, function( response ) { response = eval( '(' + response + ')' ); console.log( response ); $( this ).trigger( 'Deleted', [ response.Result ] ); } ); } } var Gap = Object.extend( Item, { Class: 'Gap', Data: { symbol:null, date:null, type:null, gap_per:null, gap_act_per:null, adr5: null, adr10: null, adr20: null, volume:null, volume20:null }, Attributes: { date_create: null, date_modify: null, date_expire: null, id: null }, Loaded: function() { console.log( 'onLoad! Ok!' ); }, Parse: function( data ) { console.log( 'Instantiating: ' + data.symbol ); this.Attributes.date_create = data.date_create; this.Attributes.date_modify = data.date_modify; this.Attributes.date_expire = data.date_expire; this.Attributes.id = data.id; this.Data.symbol = data.symbol; this.Data.date = data.date; this.Data.type = data.type; this.Data.gap_per = data.gap_per; this.Data.gap_act_per = data.gap_act_per; this.Data.adr5 = data.adr5; this.Data.adr10 = data.adr10; this.Data.adr20 = data.adr20; this.Data.volume = data.volume; this.Data.volume20 = data.volume20; return this; } } );