Fancybox 取消活动

发布于 2024-11-03 18:45:12 字数 251 浏览 0 评论 0原文

使用 Fancybox,有没有办法将事件与按 ESC 键或单击关闭按钮关联起来?我需要能够区分按下 escape 和手动调用 fancybox.close() 之间的区别。基本上,我有一系列与工作流程相关的弹出窗口,我需要知道用户是否在中间取消了流程。我查看了 onClosed 但每次实例关闭时都会触发 - 无论方法如何。

我还查看了 onCancel 事件,但似乎只有在实例加载时取消时才会触发 - 而不是在加载后按 escape 键。

谢谢你, 瑞安

With Fancybox, is there a way to associate an event with pressing the ESC key or clicking the close button? I need to be able to tell the difference between someone pressing escape and the a manual call to fancybox.close(). Basically, I have a series of popups that tie into a workflow and I need to know if the user cancelled the process in the middle. I looked at onClosed but that fires every time the instance is closed - regardless of the method.

I also looked at the onCancel event but that only seems to fire if you cancel while the instance is loading - not by pressing escape after it's loaded.

Thank you,
Ryan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在巴黎塔顶看东京樱花 2024-11-10 18:45:12

这是我要探索的一种方法:为 fancybox 的 onStart 回调编写一个函数,该函数开始侦听带有 keycode === 27(退出键)的按键事件。在 onClose 或 onCleanup 回调中,删除侦听器。

Here's an approach I would explore: Wite a function for fancybox's onStart callback that starts listening for a keypress event with keycode === 27 (escape key). In the onClose or onCleanup callback, remove the listener.

℡寂寞咖啡 2024-11-10 18:45:12

实际上已经在那里了,但是击中逃脱和“正常”关闭事件之间没有区别。我已经解决了这个问题...添加了一个标志,以便能够在这个特定进程结束时区分转义/关闭与正常退出例程。

不过还是感谢您的见解 - 我很欣赏您的回复!

瑞安

That was actually already in there, but there was no difference between hitting escape and the "normal" close event. I've resolved this though... added a flag to be able to distinguish escape / close vs. the normal exit routine at the end of this particular process.

Thanks for your insight though - I appreciate the response!

Ryan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文