Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
447 views
in Technique[技术] by (71.8m points)

javascript - jQuery / Cordova历史记录问题-iOS 9历史记录已损坏?(jQuery / Cordova history issue - iOS 9 history broken?)

i'm just working on an application.(我只是在一个应用程序上工作。)

After i started last week i added a few pages.(上周开始学习后,我添加了几页。) Today i tried to implement the backbutton and i lose my head... four hours now i tried to get it working but i'm not able to because there are some strange behaviours in iOS 9.(今天,我尝试实现后退按钮,但我却迷失了头脑……四个小时后,我试图使其正常工作,但由于iOS 9中存在一些奇怪的行为,所以我无法这样做。) So my hardware setup for better understanding:(因此,为了更好地理解我的硬件设置:) Mac Mini - OS X - Yosemite 10.10.5(Mac Mini-OS X- 优胜美地10.10.5) iPhone 6S - iOS 9.0.1 (13A405)(iPhone 6S- iOS 9.0.1(13A405)) iPhone 6+ - iOS 9.0 BETA (13A4305g)(iPhone 6+ -iOS 9.0测试版(13A4305g)) iPhone 5 - iOS 9.0 (13A344)(iPhone 5- iOS 9.0(13A344)) iPad 4 - iOS 8.3 (12F69)(iPad 4- iOS 8.3(12F69)) My application setup for better understanding:(我的应用程序设置用于更好地理解:) Cordova at version 5.3.3(Cordova 版本5.3.3) Cordova platform iOS at version 3.9.1(Cordova平台iOS版本3.9.1) jQuery at 2.1.4 minified(缩小2.1.4版的 jQuery) jQuery mobile at 1.4.5 minified(缩小1.4.5版的 jQuery mobile) The problem(问题) So i want to implement a back button inside my application via jQuery.(所以我想通过jQuery在我的应用程序中实现后退按钮。) Normaly the way would be to add a href with attributes like data-rel="back" and data-transition="reverse" .(通常,方法是添加具有诸如data-rel="back"data-transition="reverse"类的属性的href 。) So my code looks like this:(所以我的代码看起来像这样:) index.html(index.html) <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="css/index.css"> <link rel="stylesheet" type="text/css" href="css/jquery.mobile.structure-1.4.5.min.css"> <script type="text/javascript" src="js/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script> <script type="text/javascript" src="cordova.js"></script> <title>Hello World</title> </head> <body> <div data-role="page" id="page1"> This is page 1<br /> <br /> <a href="#page2" data-transition="slide"> Go to page 2 </a> </div> <div data-role="page" id="page2"> This is page 2<br /> <br /> <a href="#" data-rel="back" data-transition="reverse"> Go back to page 1 </a> </div> </body> </html> The back button is not working in iOS 9 and iOS 9.0.1.(后退按钮在iOS 9和iOS 9.0.1中不起作用。) In iOS 8.3 everything works fine.(在iOS 8.3中,一切正常。) So is there anything known about this issue?(那么,这个问题有什么已知的吗?) Someone heard about it?(有人听说过吗?) Or am i totaly wrong and did something the wrong way?(还是我完全错了,做错了什么方法?) As i'm not able to test it on android it would be great if someone could do this.(由于我无法在android上对其进行测试,因此如果有人可以做到这一点将是非常不错的。) http://codepen.io/anon/pen/vNyrgB(http://codepen.io/anon/pen/vNyrgB) Waiting for your feedback now... Thanks in advance!(立即等待您的反馈...预先感谢!)   ask by Sithys translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are many issues at the moment, but if it's about back button navigation and page flicker the fix is simple:(目前有很多问题,但是如果是关于后退按钮导航和页面闪烁的,那么修复很简单:)

$.mobile.hashListeningEnabled=false; Place that in your device ready event.(将其放置在设备就绪事件中。) Take into account though that this breaks the Android back button so you should actually only conditionally apply this when your app is also supposed to run on Android.(请注意,尽管这样做会打断Android后退按钮,所以实际上您应该仅在应用程序也应该在Android上运行时才有条件地应用此功能。) Something like:(就像是:) if ( device.platform === "iOS" ) { $.mobile.hashListeningEnabled=false; }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...