Search code examples
extjssencha-touch-2sencha-architect

Error When Ext.create(model with parameters)


When i try to compute this line

var project = Ext.create(CarboZero.model.Project,{strTitle: title ,strType: type ,strVersion: "1.0.0" ,dateEventDate: new Date() , arrCategory: "Energy"});

with this model definition

Ext.define('CarboZero.model.Project', { extend: 'Ext.data.Model',

singleton: true,

config: {
    fields: [
        {
            name: 'arrCategory'
        },
        {
            name: 'strTitle'
        },
        {
            name: 'dateEventDate'
        },
        {
            name: 'strVersion'
        },
        {
            name: 'strType'
        }
    ]
}
});

It does not work and give me the error

Uncaught TypeError: Object [object Object] has no method 'substring' 

Not quite sure what i do wrong, but im pretty sure its in the parameters has i normally write it that way and it works fine (without parameters).


Solution

  • You will get this kind of error if you had chose to make your model a Singleton. Because Singleton are initialized at app startup and that you don't ever need to do it your self.