Backbone - Url's hash becomes empty on orientation change

与世无争的帅哥 提交于 2019-12-25 02:14:16

问题


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

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