PDA

View Full Version : public method



richchri
11 Oct 2010, 9:55 AM
I'm trying to add a public method but when I try to access it I get "Prices.getFieldSets is not a function". What am I doing wrong? Code is below thanks:


var Prices= Ext.extend(Ext.Container, {
constructor: function(config) {
Ext.apply(this, {});
Prices.superclass.constructor.apply(this, arguments);
// ... etc ...
},
getFieldSets: function() {
console.log("I'm here!!!");
}
});

Prices.getFieldSets();

Condor
11 Oct 2010, 10:02 AM
Prices is a class, but you should only call methods on an INSTANCE of the class, e.g.


var prices = new Prices({...});
prices.getFieldSets();

laurentParis
11 Oct 2010, 9:55 PM
or if you need a static access


var Prices= Ext.extend(Ext.Container, {
constructor: function(config) {
Ext.apply(this, {});
Prices.superclass.constructor.apply(this, arguments);
// ... etc ...
},
getFieldSets: function() {
console.log("I'm here!!!");
}
});

Prices.prototype.getFieldSets();