在背压时关闭引导模式

编程入门 行业动态 更新时间:2024-10-27 02:21:56
本文介绍了在背压时关闭引导模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个适用于网络和移动平台的流星应用程序.

I have a meteor app for both web and mobile platforms.

我有一个引导模式,当用户按下浏览器的后退按钮(在网络应用中)或设备的后退按钮(在移动应用中)时,我需要关闭该模式.

I have a bootstrap modal in it, and I need the modal to be dismissed whenever a user presses the browser's back button (in web app), or device's back button (in mobile app).

目前,当我按下(浏览器/设备)后退按钮时,模态消失,没有任何动画,仍然显示模态的褪色背景,用户被带到上一页.

Currently, when I press (browser/device) back button, the modal disappears without any animation, the modal's faded backdrop is still displayed, and the user is taken to the previous page.

我想要的是,当模态打开时,模态(连同背景)应该关闭,带有动画,并且用户应该留在当前页面上.

What I want is that when the modal is open, the modal (along with the backdrop) should dismiss, with animation, and the user should remain on the current page.

这是我的相关代码:

$(window).on('popstate', this.handleBackPress); document.addEventListener("backbutton", this.handleBackPress, false); ... handleBackPress(event) { event.preventDefault(); event.stopPropagation(); $('.modal').modal('hide'); }

谢谢:)

在 android 中使用以下代码可以正确关闭模态,并保持在同一页面上.但是现在,它永远不会允许 back press 事件传播.

Using the following code in android dismisses the modal correctly, and stays on the same page. But now, it never ever allows the back press event to propagate.

document.addEventListener("backbutton", this.handleBackPress); ... handleBackPress(event) { $('.modal').modal('hide'); }

推荐答案

在你的函数中,添加 $('.modal-backdrop').remove();

in your function, add $('.modal-backdrop').remove();

handleBackPress(event) { event.preventDefault(); event.stopPropagation(); $('.modal').modal('hide'); $('.modal-backdrop').remove(); }

至于淡入淡出效果,你的模态应该有一个淡入淡出的类:class="modalfade"

As for the fade effect, your modal should have a fade class attached to it: class="modal fade"

更多推荐

在背压时关闭引导模式

本文发布于:2023-11-25 12:19:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629723.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   背压时

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!