Phone delay prohibits pageinit

I'm not sure if I'm using the pageinit event correctly. Iam only works with 1 data-role = "page". Each ".html file" is data-role = "content" that is shown or hidden using javascript.

    $(document).delegate("#index", "pageinit", function(event, ui) {
  cookie = null;
  isLoggedIn(); //cookie = true || false
  initRotation();
  initNavigation();
  initService();
  .....
  if (cookie == null) {
    $('#login').show();
    $('#home, #foot, #service').hide();
  } else {
    $('#login, #service').hide();
    $('#foot, #home').show();
    $('#naviHome').addClass("ui-btn-active"); // ui-state-persist?!
  }
});

      

Everything worked fine so far, but now I'm trying to let the user take a snapshot for the form. When the camera opens and the user saves that photo, the Android onRestart () event fires, which again raises the pageinit () event. My two questions are: Is my idea to show / hide divs all the time with good performance and can you prevent it from being called on the page?

+3


source to share


1 answer


You can have a variable that keeps track of where the pageinit should or should not run. and when the user opens the camera, the variable can be changed so that when it is saved and tries to run pageinit, it won't. and then switch the variable back so it can be triggered again for other events.



Also, when it comes to showing and hashing divs, it's not better for performance, but better than loading pages all the time. You might want to look into a framework that loads all your templates (html) and loads / swaps information and templates using js. Like backbone.js

0


source







All Articles