[英]Ionic2 Alert does not show if a popover is active
我有一个列表,用户可以在其中从列表项调用弹出窗口。 在弹出框内,选择一个选项后,应创建一个确认警报。
问题是当我尝试在弹出窗口打开时调用警报时,它无法正确显示。 它似乎在列表的后面,并且列表变得没有响应(不再接受点击)...
为了进行测试,建议如果我直接通过单击项目添加警报,而不是从弹出菜单中选择的选项,警报将正确显示。
在创建列表和弹出窗口的页面上:
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);
}
在弹出框内,选择一个选项并调用close函数时:
public close(event, item)
{
if (item.Callback) item.Callback(event, this.Owner);
this.ViewController.dismiss();
}
我注意到dismiss()方法正在返回诺言。 在关闭弹出窗口并调用回调异步时,我不得不添加一个延迟。
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);
}
现在可以了...但是有一个奇怪的延迟(弹出窗口完成其动画并被关闭的时间)。 可能是viewcontroller无法同时处理多个动画/组件过渡...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.