2012-05-04 8 views
0

アプリケーションが読み込まれると、app.jsが呼び出されます(これはindex.htmlで呼び出されます)。私がしたいのは、アプリケーションがapp.jsを呼び出すときです.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' 
        } 
       ] 
      } 
     ] 
    } 
}); 
+0

これを行いますあなたの 'Icon:'プロパティ。 –

+0

私は開発のためにXcodeを使用しています。通常IDEは、セミコロンがある場合は大括弧がないことを示唆しています。 xCodeにこの機能を追加して構文エラーを表示する方法はありますか? – user1315906

+0

Xcodeで作業したことがありません。ごめんなさい。それはGoogleです。 –

答えて

2

は、私はあなたが `}`を閉じていないことがわかり

// Initialize the main view 
Ext.Viewport.add({ 
    xclass:'My.view.Main' 
}); 
+0

どこのコードを正確に追加したいですか? – user1315906

+0

'//メインビューを初期化する代わりに上記の行を追加します。 Ext.Viewport.add(Ext.create( 'My.view.Main')); }、 'this .. –

関連する問題