2013-06-28 22 views
0

我想有一個自定義菜單(帶有html或按鈕,但不是「Ext.tab.Panel」)指向我想要的特定視圖。 我設法改變點擊的意見,但現在我有另一個問題...當轉到另一個視圖,.push只能運行一次

在第一次運行的應用程序,一切工作正常... ..應用程序啓動..我點擊查看我有項目列表...點擊一個項目,並推動另一個視圖的細節。作品?作品! :)

.....但這裏是問題: - 當我去一個視圖(Ext.NavigationView)有一個列表,並從那裏我推動「家」圖標,以獲得「主.js「視圖我回到」家「(按預期), - 當我點擊鏈接再次進入同一個列表時,它會顯示我的項目列表,但不會再次打開該項目的詳細信息(十二月我們推了另一種觀點來表明這一點)

有人可以幫我嗎?我究竟做錯了什麼?

這裏是我的應用程序的一些代碼:

控制器/ Details.js

Ext.define('SkSe.controller.Details', { 
extend: 'Ext.app.Controller', 

config: { 

    refs: { 
     placesContainer:'placesContainer' 
    }, 
    control: { 
     //get me the list inside the places which is inside placesContainer 
     'placesContainer places list':{ 
      itemsingletap:'onItemTap' 
      //itemtap:'onItemTap' 
     } 

    } 
} 
, 
onItemTap:function(list,index,target,record){ 

    console.log('You clicked an item'); 


    this.getPlacesContainer().push({ 
     xtype:'details', 
     title:record.data.name, 
     data:record.data 
    }) 


} 

});

控制器/ Main.js

Ext.define('SkSe.controller.Main', { 
extend: 'Ext.app.Controller', 

config: { 
    control: { 
     //define the name of the function to call when button is pressed 
     homeButton: {tap: 'goToHome'}, 
     liveButton: {tap: 'goToLive'} 
    }, 

    refs: { 
     //button must have action='something' for reference 
     homeButton: 'button[action=goToHome]', 
     liveButton: 'button[action=goToLive]' 
    } 
}, 

//定義下面

goToHome: function() {//called whenever the button is tapped 
    //debug for tapping. See in console what buton you tapped so we can assign some action 
    console.log('You clicked on a button that goes to Home (trouble!)'); 

    Ext.Viewport.animateActiveItem({xtype: 'main'},{type: 'slide',direction: 'left'}); 


}, 

goToLive: function() {//called whenever the button is tapped 
    //debug for tapping. See in console what buton you tapped so we can assign some action 
    console.log('You clicked on a button that goes to Live'); 

    Ext.Viewport.animateActiveItem({xtype: 'live'},{type: 'slide',direction: 'left'}); 

} 

所有功能});

視圖/ PlacesContainer.js

Ext.define('SkSe.view.PlacesContainer',{ 
extend:'Ext.NavigationView', 
xtype:'placesContainer', 


config:{ 
    items:[ 
     { 
      xtype:'places' 

     }, 
     { 
      xtype:'toolbar', 
      docked:'bottom', 

      items: [ 
       { 
        xtype: 'button', 
        title: 'Go to Akcije (placesContainer)', 
        iconCls: 'icon-akcije', 
        action:'goToHome' 
       }, 
       { 
        xtype: 'button', 
        title: 'Go Live (live.js)', 
        iconCls: 'icon-live', 
        action:'goToLive' 
       } 
      ] 

     } 


    ] 
} 

});

視圖/ Places.js

Ext.define('SkSe.view.Places',{ 
extend:'Ext.Panel', 
xtype:'places', 

config:{ 

    autoLoad:true, 

    title:'Akcije', 
    iconCls:'icon-akcije', 
    layout:'fit', 
    items:[ 

     { 
      xtype:'list', 
      store:'Places', 

      itemTpl:'<img src="resources/icons/{icon}"><h1>{name:ellipsis(25)}</h1><h3>{stamps}</h3>', 
      itemCls:'place-entry' 
     } 
    ] 
} 

});

+0

當您嘗試第二次按下控制檯時出現任何錯誤? –

回答

0

使用非描述性參考文獻時,我看到類似這樣的問題。嘗試添加一個id到你的按鈕並引用它們。

homeButton: '#homeButton'