Ext.getCmp无法隐藏Youtube Video Sencha Touch [英] Ext.getCmp not working on hide of Youtube Video Sencha Touch

查看:178
本文介绍了Ext.getCmp无法隐藏Youtube Video Sencha Touch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在隐藏事件中设置元素(面板)的HTML时遇到困难,以删除Sencha Touch 2中的iFrame Youtube视频。

I'm having difficulty setting the HTML of an element (a panel) on the hide event to remove an iFrame Youtube video in Sencha Touch 2.

隐藏事件正在工作并被调用,因为我在被调用的隐藏函数中有一个Ext.Msg.alert它可以正常工作,但我无法阻止视频隐藏。

The hide event is working and is being called as I have a Ext.Msg.alert in the hide function that is being called and it works, but I can't stop the video on hide.

这是我的面板代码:

Ext.define('TCApp.view.MyPanel0', {
extend: 'Ext.Panel',
alias: 'widget.mypanel0',

config: {
    hideOnMaskTap: true,
    scrollable: false,
    items: [
        {
            xtype: 'panel',
            html: '<iframe width="560" height="315" src="http://www.youtube.com/embed/-gv9RicOHNQ" frameborder="0" allowfullscreen></iframe>',
            itemId: 'videopanel',
            hideOnMaskTap: true
        }
    ]
}

});

在我的控制器中,我有这个:

In my controller I have this:

Ext.define('TCApp.controller.MyController', {
extend: 'Ext.app.Controller',
config: {
    control: {
        "#dataview": {
            itemtap: 'onDataviewItemTap'
        },
        "mypanel0": {
            hide: 'onVideopanelHide'
        }
    }
},

等......

这个:

onVideopanelHide: function(component, options) {
    Ext.Msg.alert('Test onhide event');  <-- working hide event called

    Ext.getCmp('videopanel').setHtml("");
    Ext.getCmp('videopanel').setHtml('<div id="video1"><iframe width="560" height="315" src="http://www.youtube.com/embed/NSUucup09Hc?fs=1&amp;hl=en_US&amp;rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div><img src="resources/images/thapelo3Fy.jpg" />');

}

Ext.getCmp无法正常工作,我得到了错误:'TypeError:'undefined'不是对象(评估'Ext.getCmp('videopanel')。setHtml')'

The Ext.getCmp is not working though, I get the error: 'TypeError: 'undefined' is not an object (evaluating 'Ext.getCmp('videopanel').setHtml')'

我想要设置的面板HTML on有一个'视频面板'的itemid所以我不确定是什么问题。有什么想法吗?

The panel I am trying to set the HTML on has an itemid of 'video panel' so I'm not sure what's wrong. Any ideas?

我仍然在隐藏事件中播放我的iFrame Youtube视频,我想完全删除它。

I'm still getting my iFrame Youtube video playing on the hide event and I want to remove it completely.

我也试过'Ext.getCmp('videopanel')。destroy();'但是我得到了和上面相同的错误。我只将itemid设置为videopanel而没有其他ID ...

I've also tried 'Ext.getCmp('videopanel').destroy();' but I get the same error as above. I only have itemid set as videopanel and no other ids…

提前感谢您的任何帮助......

Thanks in advance for any help…

推荐答案

嘿@Digeridoopoo只需对MyPanel0进行一次更改,

Hey @Digeridoopoo just one change into MyPanel0,

您的代码

itemId: 'videopanel',

to:

id: 'videopanel',

我在你的 onVideopanelHide 方法上为你做了类似这样的代码版本。

I did a version of you code something like this and same into your onVideopanelHide method on Controller.

Ext.define('myapp.view.MyPanel0', {
   extend: 'Ext.Panel',
   xtype: 'mypanel0',

   config: {
      hideOnMaskTap: true,
      scrollable: false,
      items: [
        {
           xtype: 'panel',
           html: '<iframe width="560" height="315" src="http://www.youtube.com/embed/-gv9RicOHNQ" frameborder="0" allowfullscreen></iframe>',
           id: 'videopanel',
           hideOnMaskTap: true
        }, {html: '<br/>'},
        {
           xtype: 'button',
           text: 'Change Video',
           width: '55%',
           handler: function() {
               Ext.getCmp('videopanel').setHtml('')
               Ext.getCmp('videopanel').setHtml('<div id="video1"><iframe width="560" height="315" src="http://www.youtube.com/embed/NSUucup09Hc?fs=1&amp;hl=en_US&amp;rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div><img src="app/images/home.png" />')
           }
        }, {html: '<br/>'},
        {
          xtype: 'button',
          text: 'Video Stop',
          width: '55%',
          handler: function() {
              Ext.getCmp('videopanel').hide()
          }
        }
     ]
  }
});

我希望这会有所帮助。 :)

这篇关于Ext.getCmp无法隐藏Youtube Video Sencha Touch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆