Sencha Touch - 视口问题

时间:2011-05-09 19:24:35

标签: mobile sencha-touch extjs viewport

我使用的是ToolbarDemo和Drew Neil的ListDemo(@nelstrom)! 一切都很完美! 但是VIEWPORT存在一个问题 - 我想!

这是我的代码:

http://www.sencha.com/forum/showthread.php?132823-Viewport-Problem

我希望有人能帮助我! 谢谢!

---------------------------

编辑: 谢谢你mistagrooves快速回答! 但现在我得到这个错误(第33行):

TypeError: Result of expression 'ToolbarDemo.views.Viewport.setActiveItem' [undefined] is not a function.

我的代码:

ToolbarDemo.views.detailPanel = Ext.extend(Ext.Panel, {
        id: 'detailpanel',
        tpl: ['<div class="live">',
                        '<div style="float:right;padding-right: 10px;padding-bottom: 10px;">{titel}</div>',
                        '<div style="text-align:center; margin-left: auto; margin-right: auto;">',
                        '<video width="280" height="280" x-webkit-airplay="allow" poster="playlive.png" controls="controls" id="video_player" style="" tabindex="0"><source src="{video}"></source></video>',
                        '</div>'],
        dockedItems: [
            {
                xtype: 'toolbar',
                items: [{
                    text: 'zur&uuml;ck',
                    ui: 'back',
                    handler: function() {
                        ToolbarDemo.views.Viewport.setActiveItem('disclosurelist', {type:'slide', direction:'right'});
                    }
                }]
            }
        ]
    });

ToolbarDemo.views.Beitrage = Ext.extend(Ext.List, {
title: "Beitr&auml;ge",
iconCls: "btnbeitraege",
id: 'disclosurelist',
        store: storeXML,
        itemTpl: '<div class="contact"><img src="{bild}" width="48" height="26" border="0"/> {titel}</div>',
        grouped: true,
        onItemDisclosure: function(record, btn, index) {
        var details = Ext.getCmp('detailpanel');
        details.update(record.data);
        //this is ok because Viewport is an object
        ToolbarDemo.views.Viewport.setActiveItem('detailpanel');
 } 
});

ToolbarDemo.views.Viewport = new Ext.Panel ({
        fullscreen: true,
        cardSwitchAnimation: 'slide',
        items: [new ToolbarDemo.views.Beitrage(), new ToolbarDemo.views.detailPanel()]
    });

storeXML.load();
Ext.reg('beitrage', ToolbarDemo.views.Beitrage);

我希望任何人都可以提供帮助! 谢谢!

1 个答案:

答案 0 :(得分:0)

问题是你没有通过'new'创建任何东西。基本上你正在玩类而不是对象。 ToolbarDemo.views.detailPanel是一个Class而不是Panel对象,因此您必须先创建它才能使用它。

您已完成(或复制它)作为主视口初始化的一部分:

ToolbarDemo.views.Viewport = new Ext.Panel ({
        fullscreen: true,
        layout: 'card',
        cardSwitchAnimation: 'slide',
        items: [new ToolbarDemo.views.Beitrage(), new ToolbarDemo.views.detailPanel()]
    });

在您的披露功能中,您可以执行以下操作:

    onItemDisclosure: function(record, btn, index) {
            var details = Ext.getCmp('detailpanel');
            details.update(record.data);
            //this is ok because Viewport is an object
            ToolbarDemo.views.Viewport.setActiveItem('detailpanel');
        }