PDA

View Full Version : Problem with creating class



schuc
13 Oct 2012, 11:31 AM
Hi everybody!

Long search and no solution.
I've build my app with ext js 4 and MVC.
Split my files/classes into (file-structure)
app/
View/
Controller/
Model/

So now i want to extend and bring in some infrastructure
I made an folder

app/
Infrastructure/
shared/
Managers

and a the js file:


Ext.define('ServiceRequest.Infrastructure.shared.Managers.FacilityControlManager',{

alias: 'widget.facilityControlManager',

constructor: function(config){
this.initConfig(config);
return this;
},

myfunc : function({
console.log('call Facility Control Manager');
})
}
});

My app.js looks like this:

Ext.application(
{
name: 'ServiceRequest',
appFolder: 'app',
autoCreateViewport: true,



How can i create an instance from my ServiceRequest.Infrastructure.shared.Managers.FacilityControlManager in my controller?

Thanks a lot for any help and suggestion.
Thomas

vietits
13 Oct 2012, 3:52 PM
You just need to load classes with requires config and then create instances with Ext.create().


Ext.define('Your controller', {
extend: 'Ext.app.Controller',
requires: ['ServiceRequest.Infrastructure.shared.Managers.FacilityControlManager'],
...
someMethod: function(){
var facilityCM = Ext.create('ServiceRequest.Infrastructure.shared.Managers.FacilityControlManager', {...});
...
}
})

schuc
14 Oct 2012, 5:44 AM
Ahhh .. i didn't call the full class in Ext.create ..

simple lost the focus.. thanks a lot again!
You helped me a lot!

Greets Thomas