Magnific Popup 和 Bootstrap 3 Modal Call Stack Exceeded

Magnific Popup and Bootstrap 3 Modal Call Stack Exceeded

我在将 Boostrap 3 Modal 与 Magnific Popup 结合使用时遇到了一个有趣的问题。我有一个包含视频列表的 Bootstrap 模式,每个视频都有一个视图 link 可以打开 Magnific Popup iframe 弹出窗口。

一切正常,直到我使用 Magnific Popup 的 z-index 来让它出现在 Bootstrap 模式的顶部。 问题是,如果您尝试关闭 Magnific Popup(或完全与之交互),则会发生 Whosebug 错误(超出最大调用堆栈)。

注意:如果我单独保留 Magnific Popup 的 z-index,一切正常。

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

注意:codepen 抑制了 SO 错误,因此问题不那么明显。但是在我的网站上,SO 发生锁定浏览器。

我认为这与在 Bootstrap 模态框外单击如何关闭模态框有关,但我将模态背景更改为静态(强制用户单击 x 或关闭按钮)但没有改变.有什么想法吗?

有人在关于同一问题的 github issue 中发布了此问题的答案。注释掉一行代码似乎很麻烦,但确实可以解决问题,到目前为止我还没有发现任何副作用。

摘自 github 用户 RandomArray 的回复

Line 375 seems to be the problem. I commented it out and the Maximum call stack size exceeded error went away.

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

如果你不想插手华丽的弹出代码, github 用户 alyak46141414 后来在相同的 issue

中提出建议

so , I did

$(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 .

这个和 Craig Harschbarger(您的)的回答都对我有用。