简体   繁体   English

超出了壮观的弹出窗口和Bootstrap 3模式调用堆栈

[英]Magnific Popup and Bootstrap 3 Modal Call Stack Exceeded

I'm having an interesting issue when combining Boostrap 3 Modal with Magnific Popup. 将Boostrap 3 Modal与Magnific Popup结合使用时遇到一个有趣的问题。 I have a Bootstrap Modal that contains a list of videos, and each video has a view link that opens up a Magnific Popup iframe popup. 我有一个包含视频列表的Bootstrap Modal,每个视频都有一个查看链接,可打开Magnific Popup iframe弹出窗口。

Everything worked fine until I played with Magnific Popup's z-index in order to get it to appear on top of the Bootstrap Modal. 在我使用Magnific Popup的z-index进行播放之前,一切工作正常,以便使其出现在Bootstrap Modal的顶部。 Problem is , if you try and close the Magnific Popup (or interact with it at all) a stackoverflow error occurs (Maximum call stack exceeded). 问题是 ,如果您尝试关闭Magnific Popup(或根本不与之交互),则会发生stackoverflow错误(超出了最大调用堆栈)。

Note: Everything works fine if I leave the z-index of the Magnific Popup alone. 注意:如果我不理会Magnific Popup的z-index ,一切都可以正常工作。

Simplified Example: http://codepen.io/craigh/pen/GoWWOK/ 简化示例: http : //codepen.io/craigh/pen/GoWWOK/

Note: codepen suppresses SO errors, so the issue is not as obvious. 注意:codepen可抑制SO错误,因此问题并不明显。 But on my site, the SO occurs locking the browser up. 但是在我的网站上,SO发生了将浏览器锁定的情况。

I think it has something to do with how clicking outside of a Bootstrap Modal closes the modal, but I changed the modal backdrop to static (forces user to click the x or close button) but no change. 我认为这与如何在Bootstrap Modal之外单击来关闭模态有关,但是我将模态背景更改为静态(强制用户单击x或close按钮),但没有更改。 Any ideas? 有任何想法吗?

Someone posted the answer to this question in a github issue about this same problem. 有人在有关此问题的github问题中发布了该问题的答案。 Commenting out a line of code seems messing it does do the trick and I haven't found any side effects as of now. 注释掉一行代码似乎弄乱了它的窍门,到目前为止,我还没有发现任何副作用。

Taken from github user RandomArray's response 取自github用户RandomArray的回应

Line 375 seems to be the problem. 375行似乎是问题所在。 I commented it out and the Maximum call stack size exceeded error went away. 我将其注释掉,并且“最大调用堆栈大小超出”错误消失了。

_document.on('focusin' + EVENT_NS, mfp._onFocusIn); _document.on('focusin'+ EVENT_NS,mfp._onFocusIn);

If you don't want to do meddle in the magnific popup code, github user alyak46141414 later suggests in the same issue 如果您不想干预宏大的弹出代码,则github用户alyak46141414稍后会在同一期中提出建议

so , I did 所以我做了

$(document).off('focusin' ); $(document).off('focusin');

after after magnific load ( any funcrion called after it loaded , you may do inside .ready(). it clear all 'focusin' handlers . no magnific popup code modification need . 大量加载后(在加载后调用的任何函数都可以在.ready()中进行操作。它会清除所有“ focusin”处理程序。无需进行大量的弹出代码修改。

Both this and Craig Harschbarger's (your) answer worked for me. 这和Craig Harschbarger(您的)的回答都对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM