2013-04-10 45 views
0

我在Sencha Touch 2有點問題:如何區分ST2中的目標後退按鈕?

我的應用程序有2個視圖/列表:新聞和事件。兩者都有詳細的意見。 在新聞列表中Iam顯示過濾器和排序按鈕,並在事件列表上Iam只想顯示過濾器按鈕。

當我點擊一個項目時,導航控制器會自動添加一個後退按鈕。

我要做的ATM是: - 當用戶單擊列表中的項目:隱藏所有的按鈕 - 當用戶單擊後退按鈕:顯示所有按鈕

並且那是問題...我無法看到它是新聞詳情視圖上的後退按鈕還是事件詳細視圖。

在我的控制,我有:

"mainnav[id=mainNav]": { 
      back: 'showButtons', 
     }, 

當我嘗試:

"panel[id=newsDetail]": { 
      back: 'showButtons', 
     }, 

事件被不會被觸發。 那麼我怎麼能知道這是新聞還是事件後退按鈕?

謝謝!

編輯:它不容易解釋...這裏是一些更多的信息: 「mainNav」是一個導航視圖,後退按鈕被添加到它的工具欄。

Ext.define('MyApp.view.MainNav', { 
extend: 'Ext.navigation.View', 
alias: 'widget.mainnav', 
config: { 
    id: 'mainNav', 
    maxWidth: '350px', 
    items: [ 
    { 
     xtype: 'tabpanel', 
     layout : { 
      type : 'card' 
     }, 
... 
items: [ 
     { 
     xtype: 'list', 
     title: 'News', 
     id: 'newsList', 
     store: 'newsStore', 
     grouped: true, 
     onItemDisclosure: true, 
... 
    { 
    xtype: 'list', 
    title: 'Events', 
    iconCls: 'team', 
    id: 'eventList', 
    store: 'eventStore', 
    onItemDisclosure: true, 
... 
    tabBar: { 
    docked: 'bottom' 
} 
... 
and the navigation bar with its buttons: 

navigationBar: { 
minWidth: '', 
width: '', 
id: 'navBar', 
layout: { 
    align: 'center', 
    type: 'hbox' 
}, 
items: [ 
{ 
    xtype: 'button', 
    id: 'settingsButton', 
    align: 'left', 
    iconCls: 'settings6', 
    iconMask: true 
}, 
    { 
    xtype: 'button', 
    id: 'filterbutton', 
    align: 'right', 
    iconCls: 'list', 
    iconMask: true 
} 
] 
}, 

什麼IAM試圖現在要做的:

"mainnav[id=mainNav]": { 
     back: 'showButtons', 
    }, 

被觸發,當用戶點擊後退按鈕(並不重要,如果他在閱讀新聞或eventsDetail ID),但我想知道哪些查看用戶看到他點擊後退按鈕後。

如果他看到新聞列表,然後我想顯示這兩個按鈕(過濾器和seetings),但他看到的事件列表我只想顯示一個按鈕。 我需要的是這樣的:如果

showButtons: function(component, options) { 
    if(Ext.getCmp(backButton).down().getId() == 'newsList'){ 
    //show 2 buttons 
    }else{ 
    //show one button 
    } 
} 

對不起答案是混亂...我不知道我怎麼能更好地解釋它。 無論如何,我會很感激任何幫助/想法!

+0

非常困惑.. – dbrin 2013-04-11 04:42:47

+0

對不起...我編輯了我以前的帖子,希望現在好轉... – Nico 2013-04-11 09:02:16

回答

0

得到了一個解決方案:

var activePanel = Ext.getCmp('MainTabPanel').getActiveItem(); 
    var activeItem = activePanel.getItemId(); 

    if(activeItem == 'newsList'){ 
     this.filterNewsStore(); 
     Ext.getCmp('showSettingsButton').show(); 
     Ext.getCmp('filterButton').show(); 
    } 

    if(activeItem == 'eventList'){ 
     this.filterEventsStore(); 
     Ext.getCmp('showSettingsButton').hide(); 
     Ext.getCmp('filterButton').show(); 
    } 

我把這個代碼時後退按鈕被炒魷魚。

0

面板沒有返回事件。所以它永遠不會被解僱。

mainnav是您定義的自定義xtype嗎?否則,選擇器也是錯誤的。