如何在 Sencha Touch 中正确销毁()我的弹出窗口

发布于 2025-01-05 04:40:37 字数 2071 浏览 5 评论 0原文

我在弹出窗口上实施 destroy 方法时遇到困难。一切工作正常,下面的代码适用于有一个弹出窗口,根据单击的内容更改其内容。但我注意到隐藏弹出窗口时我的内容(媒体)仍在播放。我想完全销毁它,然后单击重新创建。我在论坛中没有真正找到任何可以帮助我实现这一目标的东西,所以我认为它也会对其他人有所帮助:-)

有几件事让我感到困惑,因为标记上已经有一个点击侦听器,它会启动弹出窗口,我应该把销毁代码放在哪里?我是否应该将其声明为弹出窗口之外的单独函数,然后以某种方式在 beforehide 上调用它?

function addMarker(country) 
        {
    if (true) 
            {
      var image = new google.maps.MarkerImage(country.image48Path);
      var marker = new google.maps.Marker({
        map: map.map,
        title: country.title,
        position: country.position,
        //draggable: true,
        icon:image
      });


      var goToCountryWrapper = function (button, event)
                {
                    goToCountry(country, this.popup);
      };


      google.maps.event.addListener(marker, 'click', function() 
                {
        if (!this.popup) 
                    {  ---> Should I be placing destroy code here?
          this.popup = new Ext.Panel(
                            {
            floating: true,
            modal: true,
            centered: true,
            width: 800,
            height: 600,
            styleHtmlContent: true,
            scroll: 'vertical',
            items:[(new countryOverlay(country)).overlayPanel,
            {
              xtype:'button', 
              margin: 20,
              ui:'action-round',
              text:'Click here to view more promo videos',
              handler:goToCountryWrapper,
              scope : this
            },],
                layout: {
              type: 'auto',
              padding: '55',
              align: 'left'
            },
            dockedItems: [{
              dock: 'top',
              xtype: 'toolbar',
              ui: 'light',
              title: country.title
              }],
    ---> Should I be placing a listener here for beforehide, destroying here?
          });
        };
        this.popup.show('pop');

      });    
    }
  };

---> Should I be placing the destroy code after, as a seperate function?

谢谢,

迪吉里杜普

I am having difficulties implementing the destroy method on my popup. Everything works fine, the below code works for having one popup that changes its contents depending what is clicked on. But I notice that my content (media) still plays when hiding the popup. I'd like to destroy it completely, and re-create on click. I've not really found anything in the forums that helps me achieve this, so I think it will help others too :-)

There are a couple of things confusing me, as there is already a click listener on the markers, which initiates the popup, where should I put the destroy code? Should I be declaring it as a separate function outside the popup, then calling it on beforehide somehow?

function addMarker(country) 
        {
    if (true) 
            {
      var image = new google.maps.MarkerImage(country.image48Path);
      var marker = new google.maps.Marker({
        map: map.map,
        title: country.title,
        position: country.position,
        //draggable: true,
        icon:image
      });


      var goToCountryWrapper = function (button, event)
                {
                    goToCountry(country, this.popup);
      };


      google.maps.event.addListener(marker, 'click', function() 
                {
        if (!this.popup) 
                    {  ---> Should I be placing destroy code here?
          this.popup = new Ext.Panel(
                            {
            floating: true,
            modal: true,
            centered: true,
            width: 800,
            height: 600,
            styleHtmlContent: true,
            scroll: 'vertical',
            items:[(new countryOverlay(country)).overlayPanel,
            {
              xtype:'button', 
              margin: 20,
              ui:'action-round',
              text:'Click here to view more promo videos',
              handler:goToCountryWrapper,
              scope : this
            },],
                layout: {
              type: 'auto',
              padding: '55',
              align: 'left'
            },
            dockedItems: [{
              dock: 'top',
              xtype: 'toolbar',
              ui: 'light',
              title: country.title
              }],
    ---> Should I be placing a listener here for beforehide, destroying here?
          });
        };
        this.popup.show('pop');

      });    
    }
  };

---> Should I be placing the destroy code after, as a seperate function?

Thanks,

Digeridoopoo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哆兒滾 2025-01-12 04:40:37

我猜你想在隐藏弹出窗口时销毁它?如果是这样,您应该监听隐藏事件,然后销毁它。

this.popup.on('hide', function() {
    this.popup.destroy();
}, this);

I presume you want to destroy it when you hide the popup? If so, you should listen tot he hide event and then destroy it then.

this.popup.on('hide', function() {
    this.popup.destroy();
}, this);
漫漫岁月 2025-01-12 04:40:37

检查这个

             hideOnMaskTap:true,
                    listeners : {
                        hide: function() {
                          this.destroy();
                          }
                    },

Check this

             hideOnMaskTap:true,
                    listeners : {
                        hide: function() {
                          this.destroy();
                          }
                    },
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文