2012-02-13 9 views
1

ポップアップでdestroyメソッドを実装するのが難しいです。すべて正常に動作し、以下のコードはクリックされた内容に応じて内容を変更するポップアップが1つあるため動作します。しかし、ポップアップを隠しているうちに自分のコンテンツ(メディア)が再生されていることに気付きました。私は完全にそれを破壊し、クリックして再作成したいと思います。私はこれを達成するのに役立つフォーラムで実際に見つけられていないので、他の人にも役立つと思う:-)Sencha Touchでポップアップを正しく破棄する方法

マーカーにクリックリスナーが既に存在するので、これはポップアップを開始します。どこに破壊コードを入れるべきですか?ポップアップの外に別の関数として宣言する必要がありますか?

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? 

おかげで、

Digeridoopoo

答えて

2

ポップアップを非表示にしたときに、私はあなたがそれを破壊したいと推定?もしそうなら、彼はイベントを隠すトートを聞いて、その後それを破壊するべきです。

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

この

   hideOnMaskTap:true, 
        listeners : { 
         hide: function() { 
          this.destroy(); 
          } 
        }, 
をチェック
関連する問題