Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Framework needs a mobileready event. #2661

Closed
jblas opened this issue Oct 10, 2011 · 13 comments
Closed

Framework needs a mobileready event. #2661

jblas opened this issue Oct 10, 2011 · 13 comments

Comments

@jblas
Copy link
Contributor

jblas commented Oct 10, 2011

Historically folks have been waiting for the first pageshow or pagechange event to figure out when they can run their code to initialize their application. This is fine for some folks, but some developers need to know is when the framework is actually done initializing itself. Since set up of the first page, resulting in the first pageshow and pagechange, is just part of the framwork initialization, it would be nice to know definitively when it is done initializing itself.

What we really need is a mobileinitcomplete or mobileready event to tell folks the framework is initialized and ready to go.

@scottjehl
Copy link

this is before the first pagecreate, or..?

@jblas
Copy link
Contributor Author

jblas commented Oct 10, 2011

This is after all is said and done ... the point being that as PART of mobile initializing, it creates the pages, as well as other init types of things ... so folks want to know when it is all done.

@ghost ghost assigned jblas Nov 21, 2011
@jblas
Copy link
Contributor Author

jblas commented Jan 13, 2012

I took a look at what it would take to add this, so I'm just jotting down some notes here of what I noticed when looking at jquery.mobile.init.js.

  • We still fire off a DOM Ready handler even when $.mobile.autoInitializePage is false.
  • In the DOM Ready handler does 3 things:
    • Scrolls the document by 1 pixel and attempts to initialize $.mobile.defaultHomeScroll based on the results.
    • Calls $.mobile.initialzePage() conditionally based on the value of $.mobile.autoInitializePage.
    • Sets up an onload handler that executes a silentScroll() to hide the browser's nav bar.

There are a couple of problems I'm seeing that we'll need handle to accurately tell when we're all done initializing:

  • Even after initializePage() is done executing, the first page may not be ready, especially in the case where the document URL contains a hash, since it fires off a hashchange event to trigger what ever page it refers to, to load, which is an async operation.
  • We should execute the silentScroll() after the initial page is shown, or onload, whichever comes last. The reason we need to do it this way is because, the size of the page may not be accurate before the onload handler fires, because any inline images may not have loaded yet.

@toddparker
Copy link
Contributor

@scottjehl - Mind weighing in here?

@jaspermdegroot
Copy link
Contributor

In what way is this different from the pageinit event?

@pillex
Copy link

pillex commented Dec 26, 2012

i need to scroll the page when first loaded. sometimes works, sometimes jQM scrolls page back to top. probably a race condition. i guess a mobileready event would help to solve this without checking for race conditions.

@uGoMobi - probably after pageinit the framework is working heavily. after mobileready it's doing nothing

@arschmitz
Copy link
Contributor

@pillex is there a reason you cant use pageshow for this. your example seems like a situation where this would be what your looking for.

@pillex
Copy link

pillex commented Dec 26, 2012

i'm using lab.js which loads .js async. don't have the problem currently. but back then i tried everything, also pageshow. and i was looking for .bind( 'totally-finished-doing-nothing-anymore' , scroll_down() )

@yaffol
Copy link

yaffol commented May 13, 2013

I'm also using lab.js to aysnchronously load in jquery mobile and other javascript assets. It's proving difficult to find an event that can be bound to, to handle things like custom extra markup, which I previously bound to pageBeforeCreate.
When loading with lab.js, it seems that the bindings are not available, at the point at which they are called - which is synchronously after the loading of jquery mobile (lab.js with a .wait() method, which is meant to only execute the next script after the previous one has 'completed') - but I'm not sure this is actually the case in reality.

Having a 'framework has definitely finished' event would be really great :)
!

I've ended up binding to window.load - I think that a 'framework ready' event would be the answer to this.

@Ruffio
Copy link

Ruffio commented Apr 17, 2014

Can this three year old high priority issue be closed?

@arschmitz
Copy link
Contributor

I'm actually going to keep this one open there has been some recent internal discussion about this and it may actually be addressed in 1.5 assigning this to myself

@arschmitz arschmitz self-assigned this Apr 17, 2014
@apsdehal
Copy link
Contributor

@arschmitz Any updates on this? We have a "mobileinit" event.

@arschmitz
Copy link
Contributor

yes lets close it there has not been any one asking if they do we can reconsidder

@apsdehal apsdehal self-assigned this Aug 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants