How to go back in jquery mobile without triggering the animation?

寵の児 提交于 2020-01-03 02:58:06

问题


Going back in jquery mobile will trigger a $.mobile.changePage() with the location.hash as explained in the jquery mobile docs.

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.

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 ?


回答1:


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);

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.




回答2:


There is "rel=external" function in jQueryMobile and it won't trigger the animation.



来源:https://stackoverflow.com/questions/7866757/how-to-go-back-in-jquery-mobile-without-triggering-the-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!