2014-01-30 27 views
0

我正在使用sencha touch 2.3和PhoneGap来创建一个android应用程序,导航视图有问题。Sencha导航视图

main.js

Ext.define('Myapp.view.Main',{ 
extend:'Ext.navigation.View', 
xtype:'mainvi, 
requires:['Myapp.view.RedirectView','Myapp.view.IncomingJobView','Myapp.view.MapView','Myapp.view.DriverLoginFormView','Myapp.view.DashboardView','Myapp.view.AccountView'], 
id:'navview', 
fullscreen:true, 
config:{ 
items:[{ 
    xtype:'RedirectView', 
}], 
navigationBar: { 
     items: [{ 
       xtype: 'button', 
       id:'logoutButtonId', 
       hidden:true, 
       text: 'Logout', 
       align: 'right', 
       handler: function(){} 
      }], 
     docked: 'top' 
     } 
    } 
}); 

在这个项目中的着陆页是RedirectView的,有一次,当我登录,然后在下一个页面的MapView。
我用下面的代码这些。

Ext.getCmp('navview').push({ 
xtype:'MapView' 
}); 

当我点击登出按钮时,页面重定向到“RedirectView”页面。
获得RedirectView页面后,我无法进入任何其他页面。
以下警告进入控制台。
[WARN] [Ext.Component#constructor]注册一个已经使用过的id('driverLoginTextId')的组件。请确保现有的组件已经被销毁( '#Ext.Component破坏()'

,以下是我RedirectView.js文件

Ext.define('Myapp.view.RedirectView', { 
extend : 'Ext.form.Panel', 
xtype : 'RedirectView', 
requires : ['Ext.Label'], 
config : { 
    styleHtmlContent : 'true', 
    scrollable : 'false', 
    //cls:'GreenBackgroundImage', 
    style : { 
     'background-image' : 'url(resources/images/background.jpg)', 
     'background-repeat' : 'no-repeat', 
     'background-size' : '100% 100%' 
    }, 
    //title: 'Register', 
    layout : { 
     type : 'vbox', 
     align : 'center', 
     pack : 'center' 
    }, 
    items : [{ 
      xtype : 'panel', 

      items : [{ 
        xtype : 'button', 
        id : 'RedirectAirportBtnId', 
        text : 'Airport Transfer', 
        width : '200px', 
        height : '35px', 
        style : { 
         'marginBottom' : '10px' 
        }, 
       }, { 
        xtype : 'button', 
        id : 'RedirectAsDirectedBtnId', 
        text : 'As Directed', 
        width : '200px', 
        height : '35px', 
        //style:{'marginBottom':'10px'}, 

       }, { 
        layout : 'hbox', 
        xtype : 'panel', 
        flex : 1, 
        items : [{ 
          xtype : 'panel', 
          id : 'signinLinkPanelId', 
          width : '100px', 
          items : [{ 
            layout : { 
             type : 'vbox', 
             align : 'center', 
             pack : 'center' 
            }, 
            items : [{ 
              xtype : 'label', 
              html : '<a href="#" style="font-size:17px;text-decoration:none;color:#2E3604;text-align:center" onclick=createLoginPage("passengerLoginTextId");><center>Sign in</center></a>', 
              styleHtmlContent : true 
             } 
            ] 
           } 
          ] 
         }, { 
          xtype : 'panel', 
          id : 'takeATourLinkPanelId', 
          flex : 1, 
          items : [{ 
            layout : { 
             type : 'vbox', 
             align : 'center', 
             pack : 'center' 
            }, 
            items : [{ 
              xtype : 'label', 
              html : '<a href="#" style="font-size:17px;text-decoration:none;color:#2E3604">Take a tour</a>', 
              styleHtmlContent : true 
             } 
            ] 

           } 
          ] 

         } 
        ] 
       }, { 
        layout : { 
         type : 'vbox', 
         align : 'center', 
         pack : 'center' 
        }, 
        items : [{ 

          xtype : 'label', 
          id : 'signinAsDriverLinkId', 
          html : '<a href="#" style="font-size:17px;text-decoration:none;color:#2E3604" onclick=createLoginPage("driverLoginTextId");>Login as driver</a>', 
          styleHtmlContent : true, 
          style : { 
           'marginTop' : '-20px' 
          } 
         }, { 
          xtype : 'label', 
          id : 'registerLinkId', 
          html : '<a href="#" style="font-size:17px;text-decoration:none;color:#2E3604" onclick=redirectToRegisterPage();>Register</a>', 
          styleHtmlContent : true, 
          style : { 
           'marginTop' : '-20px' 
          } 
         } 
        ] 
       } 
      ] 
     } 
    ] 

} 

});

重定向页面是否存在任何错误?
如何销毁已在navigationView Array中创建的组件?

回答

0

先试着得到你想要的推动,如果没有找到,然后用ID创建视图视图

var myMapView = Ext.getCmp('myMapView'); 
if(!myMapView){ 
    myMapView = Ext.create('Myapp.view.MapView', { id: "myMapView" }); 
} 

Ext.getCmp('navview').push(myMapView);