アプリケーションが読み込まれると、app.js が呼び出されます (これは index.html で呼び出されます)。私がやりたいのは、アプリが app.js を呼び出すときです。Main.js ビューを初期化するには app.js が必要です。
簡単に言えば、app.js が呼び出されると、Main.js ビューを呼び出す必要があります。
プログラムでこれを行うにはどうすればよいですか。
app.js
//<debug>
Ext.Loader.setPath({
'Ext': 'lib/touch/src'
});
//</debug>
Ext.application({
name: 'My',
requires: [
'Ext.MessageBox'
],
views: ['Main'],
icon: {
phoneStartupScreen: 'resources/loading/Homescreen.jpg',
tabletStartupScreen: 'resources/loading/Homescreen~ipad.jpg',
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the main view
Ext.Viewport.add(Ext.create('My.view.Main'));
},
onUpdated: function() {
}
});
Main.js
Ext.define("My.view.Main", {
extend: 'Ext.tab.Panel',
requires: ['Ext.TitleBar'],
config: {
tabBarPosition: 'bottom',
items: [
{
title: 'Welcome',
iconCls: 'home',
styleHtmlContent: true,
scrollable: true,
items: {
docked: 'top',
xtype: 'titlebar',
title: 'Welcome to Sencha Touch 2'
},
html: [
"You've just generated a new Sencha Touch 2 project. What you're looking at right now is the ",
"contents of <a target='_blank' href=\"app/view/Main.js\">app/view/Main.js</a> - edit that file ",
"and refresh to change what's rendered here."
].join("")
},
{
title: 'Get Started',
iconCls: 'action',
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Getting Started'
},
{
xtype: 'video',
url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
}
]
}
]
}
});