当背部被点击浏览器的按钮,引导模式是封闭的,但情态,dropback住宿 [英] When browser back button is clicked, bootstrap modal is closed but modal-dropback stays

查看:117
本文介绍了当背部被点击浏览器的按钮,引导模式是封闭的,但情态,dropback住宿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的骨干与引导。问题是,当你办理申请,并在某些时候,你打开引导模式窗口和preSS后退按钮,模态窗口关闭,但语气背景格(模态-背景)保持并不会消失。它覆盖整个屏幕,你不能点击任何东西。我注意到,当您关闭模态正常,背景格是由html和在这种情况下它保持删除。

I am using Backbone with bootstrap. Problem is when you go through application and in some point you open bootstrap modal window and press back button, modal window closes but modal background div (modal-backdrop) stays and does not disappear. It overlays whole screen and you cant click on anything. I noticed that when you close modal normally modal-backdrop div is removed from html and in this situation it stays.

我正在寻找在网络这个解决方案,并发现类似的事情,但他们都不是大潮浏览器后退按钮pressed。

I was searching for this solution on web, and found similar things, but none of them were tide with browser back button pressed.

我想过追赶浏览器的后退按钮的事件和用户的jQuery删除该分区,但是这是不是真的很好的解决方案。

I thought about catching browser back button event and user jquery to remove that div, but that is not really good solution.

有人能指出这个问题的一些解决方案?或者在最后告诉我这是为什么发生的事情。

Can someone point out some solutions for this problem? Or at last tell me why is that happening.

编辑:
当后退按钮pressed,模态不会抛出hide.bs.modal事件,所以我不能抓住它,并删除模式,背景DIV

When back button is pressed, modal does not throw hide.bs.modal event, so i cant catch it and remove modal-backdrop div

推荐答案

您可以收听到HTML5 popstate 事件,然后触发隐藏。 bs.modal 事件如果您发现该模式,背景显示。

You can listen to the HTML5 popstate event and then fire the hide.bs.modal event if you find that the modal-backdrop is displayed.

$(window).on('popstate', function() {
  alert('Back button was pressed.');
});

或者使用 History.js 工具,它的的事件赶上后退按钮事件,然后做同样为previous解决方案。

Or use the History.js tool and it's events to catch the back button event and then do the same as the previous solution.

这篇关于当背部被点击浏览器的按钮,引导模式是封闭的,但情态,dropback住宿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆