X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/source/ModelManager.html?ds=sidebyside diff --git a/docs/source/ModelManager.html b/docs/source/ModelManager.html index a086af24..6d1f6ee7 100644 --- a/docs/source/ModelManager.html +++ b/docs/source/ModelManager.html @@ -1,4 +1,21 @@ -Sencha Documentation Project
/**
+
+
+
+  
+  The source code
+  
+  
+  
+  
+
+
+  
/**
  * @author Ed Spencer
  * @class Ext.ModelManager
  * @extends Ext.AbstractManager
@@ -6,27 +23,36 @@
 The ModelManager keeps track of all {@link Ext.data.Model} types defined in your application.
 
 __Creating Model Instances__
-Model instances can be created by using the {@link #create} function. It is also possible to do
-this by using the Model type directly. The following snippets are equivalent:
+
+Model instances can be created by using the {@link Ext#create Ext.create} method. Ext.create replaces
+the deprecated {@link #create Ext.ModelManager.create} method. It is also possible to create a model instance
+this by using the Model type directly. The following 3 snippets are equivalent:
 
     Ext.define('User', {
         extend: 'Ext.data.Model',
         fields: ['first', 'last']
     });
-    
-    // method 1, create through the manager
+
+    // method 1, create using Ext.create (recommended)
+    Ext.create('User', {
+        first: 'Ed',
+        last: 'Spencer'
+    });
+
+    // method 2, create through the manager (deprecated)
     Ext.ModelManager.create({
         first: 'Ed',
         last: 'Spencer'
     }, 'User');
-    
-    // method 2, create on the type directly
+
+    // method 3, create on the type directly
     new User({
         first: 'Ed',
         last: 'Spencer'
     });
-    
+
 __Accessing Model Types__
+
 A reference to a Model type can be obtained by using the {@link #getModel} function. Since models types
 are normal classes, you can access the type directly. The following snippets are equivalent:
 
@@ -34,10 +60,10 @@ are normal classes, you can access the type directly. The following snippets are
         extend: 'Ext.data.Model',
         fields: ['first', 'last']
     });
-    
+
     // method 1, access model type through the manager
     var UserType = Ext.ModelManager.getModel('User');
-    
+
     // method 2, reference the type directly
     var UserType = User;
 
@@ -48,18 +74,17 @@ Ext.define('Ext.ModelManager', {
     extend: 'Ext.AbstractManager',
     alternateClassName: 'Ext.ModelMgr',
     requires: ['Ext.data.Association'],
-    
+
     singleton: true,
-    
+
     typeName: 'mtype',
-    
+
     /**
      * Private stack of associations that must be created once their associated model has been defined
-     * @property associationStack
-     * @type Array
+     * @property {Ext.data.Association[]} associationStack
      */
     associationStack: [],
-    
+
     /**
      * Registers a model definition. All model plugins marked with isDefault: true are bootstrapped
      * immediately, as are any addition plugins defined in the model config.
@@ -81,7 +106,7 @@ Ext.define('Ext.ModelManager', {
         this.types[name] = model;
         return model;
     },
-    
+
     /**
      * @private
      * Private callback called whenever a model has just been defined. This sets up any associations
@@ -93,22 +118,22 @@ Ext.define('Ext.ModelManager', {
             length = stack.length,
             create = [],
             association, i, created;
-        
+
         for (i = 0; i < length; i++) {
             association = stack[i];
-            
+
             if (association.associatedModel == model.modelName) {
                 create.push(association);
             }
         }
-        
+
         for (i = 0, length = create.length; i < length; i++) {
             created = create[i];
             this.types[created.ownerModel].prototype.associations.add(Ext.data.Association.create(created));
             Ext.Array.remove(stack, created);
         }
     },
-    
+
     /**
      * Registers an association where one of the models defined doesn't exist yet.
      * The ModelManager will check when new models are registered if it can link them
@@ -119,10 +144,11 @@ Ext.define('Ext.ModelManager', {
     registerDeferredAssociation: function(association){
         this.associationStack.push(association);
     },
-    
+
     /**
      * Returns the {@link Ext.data.Model} for a given model name
      * @param {String/Object} id The id of the model or the model instance.
+     * @return {Ext.data.Model} a model class.
      */
     getModel: function(id) {
         var model = id;
@@ -131,27 +157,41 @@ Ext.define('Ext.ModelManager', {
         }
         return model;
     },
-    
+
     /**
      * Creates a new instance of a Model using the given data.
+     *
+     * This method is deprecated.  Use {@link Ext#create Ext.create} instead.  For example:
+     *
+     *     Ext.create('User', {
+     *         first: 'Ed',
+     *         last: 'Spencer'
+     *     });
+     *
      * @param {Object} data Data to initialize the Model's fields with
      * @param {String} name The name of the model to create
-     * @param {Number} id Optional unique id of the Model instance (see {@link Ext.data.Model})
+     * @param {Number} id (Optional) unique id of the Model instance (see {@link Ext.data.Model})
      */
     create: function(config, name, id) {
         var con = typeof name == 'function' ? name : this.types[name || config.name];
-        
+
         return new con(config, id);
     }
 }, function() {
-    
+
     /**
-     * Creates a new Model class from the specified config object. See {@link Ext.data.Model} for full examples.
-     * 
+     * Old way for creating Model classes.  Instead use:
+     *
+     *     Ext.define("MyModel", {
+     *         extend: "Ext.data.Model",
+     *         fields: []
+     *     });
+     *
+     * @param {String} name Name of the Model class.
      * @param {Object} config A configuration object for the Model you wish to create.
      * @return {Ext.data.Model} The newly registered Model
      * @member Ext
-     * @method regModel
+     * @deprecated 4.0.0 Use {@link Ext#define} instead.
      */
     Ext.regModel = function() {
         //<debug>
@@ -162,4 +202,6 @@ Ext.define('Ext.ModelManager', {
         return this.ModelManager.registerType.apply(this.ModelManager, arguments);
     };
 });
-
\ No newline at end of file +
+ +