转到另一个视图时,.push只能运行一次

时间:2013-06-28 09:15:02

标签: extjs sencha-touch sencha-touch-2 sencha-touch-2.1

我想要一个自定义菜单(带有html或按钮,但不是“Ext.tab.Panel”)指向我想要的特定视图。 我设法在点击时更改了视图,但现在我有另一个问题......

首次运行应用程序时,一切正常...... ..App启动..我点击View我在哪里有项目列表...点击一个项目,然后推送另一个包含详细信息的视图。作品?作品! :)

.....但问题是: - 当我去一个有列表的视图(Ext.NavigationView)时,从那里我按下“home”图标以获得“Main.js”视图我返回“home”(如预期的那样), - 当我点击再次进入相同列表的链接时,它会显示项目列表,但不会再次打开该项目的详细信息(请重新显示我们推送另一个视图以显示此项目)

有人可以帮帮我吗?我做错了什么?

以下是我的应用的一些代码:

控制器/ 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'
        }
    ]
}

});

1 个答案:

答案 0 :(得分:0)

使用非描述性引用时,我发现了类似的问题。尝试在您的按钮上添加一个ID并通过它引用它们。

即。 homeButton: '#homeButton'