简体   繁体   中英

Backbone.js + iOS9 = strange collection behavior

I have a Cordova-based mobile app. Currently I'm preparing new version for iOS 9 and I've encountered strange situation. In this app I have Backbone 1.2.3. Every collection I have is messed up. In Safari WebInspector I can see all methods (both Backbone and Underscore), but when I try to run one (eg toJSON or filter) it returns an empty array. So it's breaking my app :( I've checked the app on Android (Nexus 5 with 5.1.1 system version) and it all runs ok. Same thing on iOS 8.3 - everything is good.

What's going on? Is this iOS9 UIWebView bug or something?

Not quite sure what you encountered. But as far as I know there is a bug on backbone when you intend to change the location hash or location href, the changes are not immediate.

This issue might be caused by Event loop. If you change the location.hash rapidly somewhere in your code, that might be the same issue.

To solve that, try to do this

window.setTimeout(function () {
    //your updating url code or fetching data code
    updateUrl();
}, 0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM