Mercurial > pub > ImplabJs
comparison core/src/js/data/_ModelBase.js @ 29:acdcdf1a8d21
repository reorganized
author | cin |
---|---|
date | Tue, 26 Jun 2018 19:35:44 +0300 |
parents | src/implab/data/_ModelBase.js@fc2517695ee1 |
children |
comparison
equal
deleted
inserted
replaced
28:d796bbbe558c | 29:acdcdf1a8d21 |
---|---|
1 define(["dojo/_base/declare"], function(declare) { | |
2 | |
3 return declare(null, { | |
4 dataContext : null, | |
5 idField : "id", | |
6 loaded : false, | |
7 | |
8 constructor : function(opts){ | |
9 if (opts) { | |
10 if(opts.dataContext) | |
11 this.dataContext = opts.dataContext; | |
12 if(opts.id) | |
13 this[this.idField] = opts.id; | |
14 } | |
15 }, | |
16 | |
17 getId : function() { | |
18 return this[this.idField]; | |
19 }, | |
20 | |
21 attach : function(id, dc) { | |
22 if (this.dataContext) | |
23 throw new Error("The object is already attached"); | |
24 this[this.idField] = id; | |
25 this.dataContext = dc; | |
26 }, | |
27 | |
28 isAttached : function() { | |
29 return this.dataContext ? true : false; | |
30 }, | |
31 | |
32 onPopulate : function() { | |
33 this.loaded = true; | |
34 } | |
35 | |
36 }); | |
37 }); |