问题
I'm developing a Phonegap mobile application, using jQuery Mobile, Backbone and RequireJS. I configured jQM to let Backbone manage the routing.
Whenever I change the orientation of the device, it seems that the whole layout is being rendered again (the first second or so, I can see just plain text, without the jQM visual enhancements and paging, and this happens when the app starts executing as well) and it goes to the first page, even though another one was being displayed. Did somebody experience this same issue?
EDIT:
The layout wasn't being enhanced by jQM because it was being loaded asynchronously by RequireJS before the body was but, why does this happen on orientation change? jQM is already loaded in the DOM, am I misunderstanding the RequireJS's workflow? Is there any way to load some libraries with RequireJS before the body gets loaded? If not, I will end up loading jQuery, jQM and the jQM configurations file synchronously.
And about the routing thing, I didn't fin out anything yet, suppose it has something to do with the Backbone router not being able to handle the url hash correctly.
EDIT 2:
Somehow, whenever I rotate the device, the url's hash becomes empty. That way, the app goes to the first page. Find below the contents of the jQM's config file:
define(['jquery'], function ($) {
$(document).on("mobileinit", function () {
$.mobile.ajaxEnabled = false;
$.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
$.mobile.defaultDialogTransition = "none";
$.mobile.defaultPageTransition = "slidedown";
});
});
来源:https://stackoverflow.com/questions/13327798/backbone-urls-hash-becomes-empty-on-orientation-change