I am currently developing the application mainly for self-learning purposes, and since I'm still not quite used to js, I can use some help to solve my problem:
In my application, I use the Javascript library (jqMobi), which is used to manipulate the DOM, page transitions, ajax calls, etc., and I also use phonegap to access device features such as geolocation.
When I launch my application, I want to get the device’s geolocation, send an ajax (jsonp) request to my server (including the device’s geolocation), which returns an array of JSON objects that I will use to create the list.
Before I can get geolocation, I need to wait for the phone gap to load. And before using jqMobi to call ajax and process the response, I need to wait for it to load.
So I basically need the events that I listen to
document.addEventListener("DOMContentLoaded",execute_this,false); //jqMobi is now ready document.addEventListener("deviceready", execure_sth, false); //Phonegap is now ready
How to execute a function as soon as both of these events have worked, and not earlier?
If I used jQuery, I would use its $.Deferred objects and its When ... Then function, but since I do not have access to them, I am looking for an alternative.
marius2k12
source share