Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs Sencha触摸列表项在视图更改后点击_Extjs_Sencha Touch - Fatal编程技术网

Extjs Sencha触摸列表项在视图更改后点击

Extjs Sencha触摸列表项在视图更改后点击,extjs,sencha-touch,Extjs,Sencha Touch,在SenchaTouch应用程序中,我得到了一些视图,其中一个包含一个列表 如果我从包含列表的视图切换到另一个视图,然后再切换回来,则不会再次触发list itemtap事件 我的列表视图: Ext.define('app.view.ItemList', { extend: 'Ext.navigation.View', xtype: 'listitems', config: { title: 'List', items: [ { xtype: 'too

在SenchaTouch应用程序中,我得到了一些视图,其中一个包含一个列表

如果我从包含列表的视图切换到另一个视图,然后再切换回来,则不会再次触发list itemtap事件

我的列表视图:

Ext.define('app.view.ItemList', {
extend: 'Ext.navigation.View',
xtype: 'listitems',

config: {
    title: 'List',

    items: [
    {
        xtype: 'toolbar',
        ui: 'light',
        docked: 'top',
        title: 'List',
        items: [
            {
                xtype: 'button',
                text: 'Back',
                ui: 'back',
                handler: function() {

                    Ext.Viewport.animateActiveItem({xtype:'main'}, {type:'slide'});
                }
            },
        ]
    },
    {
        xtype: 'list',
        itemTpl: '{"name"}',
        store: {
            autoLoad: true,
            fields: ['name', 'email'],
            proxy: {
                type: 'rest',
                url: 'data/data.json',
                reader: {
                    type: 'json'
                }
            }
        }
    }]
},
initialize: function() {

    this.callParent();
}
})
Ext.define('app.controller.Main', {
extend: 'Ext.app.Controller',

config: {
    refs: {
        listitems: 'listitems'
    },
    control: {
        'listitems list': {
            itemtap: 'showItem',
        }
    }
},
showItem: function(list, index, element, record) {

    this.getItemlist().push({

        xtype: 'panel',
        title: record.get('name'),
        html: [
            "<b>Name:</b> " + record.get('name') +
            "<b>Email:</b> " + record.get('email')
        ],
        scrollable: true,
        styleHtmlContent: true
    })
 }
 })
此控制器:

Ext.define('app.view.ItemList', {
extend: 'Ext.navigation.View',
xtype: 'listitems',

config: {
    title: 'List',

    items: [
    {
        xtype: 'toolbar',
        ui: 'light',
        docked: 'top',
        title: 'List',
        items: [
            {
                xtype: 'button',
                text: 'Back',
                ui: 'back',
                handler: function() {

                    Ext.Viewport.animateActiveItem({xtype:'main'}, {type:'slide'});
                }
            },
        ]
    },
    {
        xtype: 'list',
        itemTpl: '{"name"}',
        store: {
            autoLoad: true,
            fields: ['name', 'email'],
            proxy: {
                type: 'rest',
                url: 'data/data.json',
                reader: {
                    type: 'json'
                }
            }
        }
    }]
},
initialize: function() {

    this.callParent();
}
})
Ext.define('app.controller.Main', {
extend: 'Ext.app.Controller',

config: {
    refs: {
        listitems: 'listitems'
    },
    control: {
        'listitems list': {
            itemtap: 'showItem',
        }
    }
},
showItem: function(list, index, element, record) {

    this.getItemlist().push({

        xtype: 'panel',
        title: record.get('name'),
        html: [
            "<b>Name:</b> " + record.get('name') +
            "<b>Email:</b> " + record.get('email')
        ],
        scrollable: true,
        styleHtmlContent: true
    })
 }
 })
Ext.define('app.controller.Main'{
扩展:“Ext.app.Controller”,
配置:{
参考文献:{
listitems:“listitems”
},
控制:{
“列表项列表”:{
itemtap:“showItem”,
}
}
},
showItem:函数(列表、索引、元素、记录){
这是.getItemlist().push({
xtype:'面板',
标题:record.get('name'),
html:[
名称:“+record.get('Name'))+
“电子邮件:”+记录。获取('Email'))
],
可滚动:对,
styleHtmlContent:true
})
}
})
我也用id,itemId试过了,没用


我怎样才能解决这个问题呢?

请尝试以下方法:

this.getItemlist().push(
    Ext.create('Ext.panel.Panel,{
        title: record.get('name'),
        html: [
            "<b>Name:</b> " + record.get('name') +
            "<b>Email:</b> " + record.get('email')
        ],
        scrollable: true,
        styleHtmlContent: true
    })
)
this.getItemlist().push(
Ext.create('Ext.panel.panel{
标题:record.get('name'),
html:[
名称:“+record.get('Name'))+
“电子邮件:”+记录。获取('Email'))
],
可滚动:对,
styleHtmlContent:true
})
)

单击“后退”按钮时,不要忘记使用
getItemlist().pop()
!在我的应用程序中,后退按钮没有(或不总是)删除堆栈顶部的视图。添加加载掩码和操作表时,情况会变得更糟。

您确定tap事件不会再次触发吗?您的
showItem
函数包含什么,我希望它只是类似于
console.log('tapped')
?您使用的是哪个版本的ST,您介意在“sencha fiddle”中添加一个最小的示例吗?您明白了,我签入了控制台,它每次都会启动,所以问题出在showItem函数上。我更新了问题以显示函数。用其他方法解决了问题,但我很好奇问题出在哪里。
getItemlist()
返回的是什么?我从未在任何地方见过这样的代码(至少不起作用)。通常你会
Ext.create
一个视图。基本上我在这里构建了完全相同的视图,然后我在其中添加了一个简单的按钮:
Ext.Viewport.animateActiveItem({xtype:'main'},{type:'slide'}),但当我从该视图切换回列表视图并单击tap事件时,将激发但不加载该项