2016-09-12 59 views
0

我有一個列表,用戶可以從列表項目中調用彈出窗口。 在彈出窗口中,當選擇一個選項時,應該創建一個確認提醒。Ionic2 Alert不顯示彈出窗口是否處於活動狀態

問題是當我試圖在彈出窗口打開時調用警報時,它不能正確顯示。它似乎在名單後面,名單變得沒有響應(不能接受點擊了)...

對於測試建議,如果我直接從項目點擊添加警報,而不是從彈出窗口,警報顯示正確。

在其中的列表和酥料餅被創建的頁面:

public OnItemOptionsPress(event, item) 
    { 
     event.stopPropagation(); 

     let popoverOptions = 
     [ 
       { 
        Resource: "Remove", 
        Icon: "icon-trash",    
        Callback: (event, item) => 
        { 
          this.confirmRemoveItem(event, item) 
        }, 
       } 
     ]; 

     let popover = this.PopoverController.create 
     (
       PopoverOptions, 
       { 
        Owner: item, 
        Items: this.popoverOptions 
       } 
     ); 

     popover.present({ ev:event }); 
    } 

    public confirmRemoveItem(event, item) 
    { 
     let alert = this.AlertController.create 
     (
       { 
        title: 'Remove Item', 
        message: 'Do you want to remove?', 
        buttons: 
        [ 
          { 
           text: 'No', 
           role: 'cancel', 
           handler:() => 
           { 
             console.log('No has been clicked'); 
           } 
          }, 
          { 
           text: 'Yes', 
           handler:() => 
           { 
             console.log('yes has been clicked'); 

             this.removeItem(item); 
           } 
          } 
        ] 
       } 
     ); 

     alert.present(); 
    } 

    public removeItem(item) 
    { 
     this.items.splice(item.Index, 1); 
    } 

的酥料餅內的選項被選中時和關閉功能被稱爲:

public close(event, item) 
    { 
     if (item.Callback) item.Callback(event, this.Owner); 

     this.ViewController.dismiss(); 
    } 
+0

您能否使用您的代碼創建[plunker](https://plnkr.co/edit/vEjjdH)演示程序? – sebaferreras

回答

1

我注意到解僱( )方法正在返回一個承諾。 我不得不在添加延遲時關閉彈出窗口並調用回調異步。

public close(event, item:PopoverItemModel) 
    {  
     let animation = this.ViewController.dismiss(); 

     animation.then(()=> 
     { 
       if (item.Callback) item.Callback(this.Owner); 
     }); 

     //if (item.Callback) item.Callback(this.Owner); 
    } 

現在,它的工作原理......但有一個奇怪的延遲(該酥料餅的花費來完成他的動畫和被解僱的時間)。可能視圖控制器無法同時處理多個動畫/組件轉換...

相關問題