Fancybox 取消活动
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我要探索的一种方法:为 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.
实际上已经在那里了,但是击中逃脱和“正常”关闭事件之间没有区别。我已经解决了这个问题...添加了一个标志,以便能够在这个特定进程结束时区分转义/关闭与正常退出例程。
不过还是感谢您的见解 - 我很欣赏您的回复!
瑞安
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