如何在不触发动画的情况下返回jquery mobile? [英] How to go back in jquery mobile without triggering the animation?
问题描述
在jquery mobile中返回 会触发$.mobile.changePage()
和location.hash
,如jquery mobile文档中所述.
Going back in jquery mobile will trigger a $.mobile.changePage()
with the location.hash
as explained in the jquery mobile docs.
除了浏览器的历史记录被最后N个元素缩短以外,我将无法执行history.go(-N)
而没有任何事情.
I wan't to be able to do a history.go(-N)
without anything happening except the history of the browser being shortened by the last N elements.
所以我希望避免$.mobile.changePage()
的动画会隐藏和显示另一个页面.
So I wish to avoid the animation of $.mobile.changePage()
that will hide and show a different page.
有可能吗?如何实现呢?
Is it possible ?, and how can I achieve this ?
推荐答案
这是我所做的,但是我对此一点都不满意.但这可以解决问题.
This what I did, but I'm not happy at all with it. But it does the trick.
$.mobile.hashListeningEnabled = false;
history.go(-history_steps);
...
setTimeout(function() {
$.mobile.hashListeningEnabled = true;
}, 300);
这里是超时,尝试在触发实际hashchange
事件后重新启用正常行为.
The timeout is here to try to re-enable the normal behavior after the real hashchange
event is triggered.
如果有人可以提供更好的解决方案,我将非常高兴.
I would be really happy if someone could have a better solution.
这篇关于如何在不触发动画的情况下返回jquery mobile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!