如何在 jQuery Mobile 中检测/查询当前正在进行的页面更改/转换?
如何检测/查询 jQuery Mobile (jQM) 中当前是否正在进行页面更改/转换?
我的目标是防止在页面之间切换时打开对话框。目前,当页面更改事件正在进行时打开对话框时,UI 会中断。
对此有什么想法吗?
How can I detect/query, whether a changepage / transition is currently ongoing in jQuery Mobile (jQM)?
My goal is to prevent opening a dialog when a switch between pages is currently happening. Currently, th UI breaks when a dialog opens while a changepage event is ongoing.
Any Ideas on that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 JQM 1.4.0 中,
ui-mobile-viewport-transitioning
类在转换期间添加了body
标记,因此以下内容对我有用:In JQM 1.4.0 the class
ui-mobile-viewport-transitioning
is added thebody
tag during transitions so the following works for me:在正在显示的页面上、转换开始之前触发。
在页面被隐藏、转换开始之前触发。
在转换完成后正在显示的页面上触发。
在页面转换完成后被隐藏时触发。
http://jquerymobile.com/demos/1.0a4.1/ #docs/api/events.html
Triggered on the page being shown, before its transition begins.
Triggered on the page being hidden, before its transition begins.
Triggered on the page being shown, after its transition completes.
Triggered on the page being hidden, after its transition completes.
http://jquerymobile.com/demos/1.0a4.1/#docs/api/events.html
我没有在 jQuery Mobile 中找到过渡状态信息,但是您可以简单地添加三个事件,一个在更改之前,一个在更改之后,一个在页面更改失败时添加。然后,将当前是否发生转换保留在全局变量中:
在本例中,我创建了一个全局变量
transitioning
但您可以在您认为合适的位置创建此变量,例如在对话框中创建一个局部变量处理程序而不是使用全局变量。您现在可以像这样添加您的条件:
I didn't find transition state information within jQuery Mobile, however you can simply add three events, one before and one after the change and one for when the page change has failed. Then, keep in a global variable whether a transition is currently occuring:
In this example, I create a global variable
transitioning
but you could create this variable where you see fit, e.g. making a local variable in your dialog handler rather than using a global variable.You can now add your condition like this: