PDA

View Full Version : Is that a way add sub-directory under MVC



vnggui
4 Dec 2013, 5:58 PM
typically, Sencha requires app file structure as the following, the framework will hook controller, view automatically.

-app
-- controller
-- model
-- store
-- view

Is that possible to make the below structure working as well:

-app
-- controller
----- tablet
----- desktop
-- model
----- tablet
----- desktop
-- store
----- tablet
----- desktop
-- view
----- tablet
----- desktop

scottmartin
4 Dec 2013, 6:53 PM
Sure ... and make sure you add the DIR name to the class as well.

vnggui
5 Dec 2013, 3:20 PM
I add DIR name to class, like Myapp.view.desktop.Main, but this give errors.

I solve it by

//tablet
Ext.Loader.setConfig({
enabled: true,
paths: {
//tablet
'MyApp.controller': 'app/controller/tablet',
'MyApp.view': 'app/view/tablet',
'MyApp.store': 'app/store/tablet',
'MyApp.model': 'app/model/tablet',

//common
'Common.util':'app/common'
}
});
//desktop
Ext.Loader.setConfig({
enabled: true,
paths: {
//desktop
'MyApp.controller': 'app/controller/desktop',
'MyApp.view': 'app/view/desktop',
'MyApp.model': 'app/model/desktop',
'MyApp.store': 'app/store/desktop',
//common
'Common.util':'app/common'
}
});


and launch different app.js based userAgent detection.

This works for me to launch different API by device type, and share common code.