PDA

View Full Version : Ext.create()



matrx
5 Sep 2016, 2:17 AM
Hi,

I was trying to create a class as it is shown here http://docs.sencha.com/extjs/6.0.2-classic/guides/core_concepts/classes.html:


<code>
Ext.onReady(function(){
Ext.define('My.sample.Person', {
name: 'Unknown',

constructor: function(name) {
if (name) {
this.name = name;
}
},

eat: function(foodType) {
alert(this.name + " is eating: " + foodType);
}
});

var bob = Ext.create('My.sample.Person', 'Bob');

bob.eat("Salad"); // alert("Bob is eating: Salad");
});


</code>

The thing is that i have to use ExtJS 3.4.1 and i understand that this example maybe irrevelant for my version of ExtJS. I get error message:
types[(intermediate value)] is not a constructor I browsed the docs for 3.4.0 Ext.create() (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext-method-create) function. I am not sure how should the second parameter look like.


<code>
var bob = new My.sample.Person('Bob');
</code> works fine, but i want to acomplish this with Ext.create().

Any help will be appreciated.
Thanks very much.