I´m working on an app using PhoneGap, JQuery
I have 2 standard javascript functions.
LoadLanguage()
will make an Ajax call to get a language file and then set up a Javascript object.
SetLanguage() will use the previous object (set in LoadLanguage()) and then set some variables with the correct language.
So in my js file i have this code:
function LoadLanguage()
{
....make ajax call and set up an object
}
function SetLanguage()
{
....set language based of previous LoadLanguage()
}
$( '#startpage' ).live( 'pagebeforecreate',function(event)
{
LoadLanguage();
....
}
$( '#startpage' ).live( 'pagebeforeshow',function(event)
{
SetLanguage();
....
}
Problem is that the SetLanguage()
will fire before LoadLanguage()
is done. I could solve this problem running SetLanguage()
inside the LoadLanguage ajax.complete
. But this is not good since i need to call SetLanguage()
in other parts of my code.
So how do i solve this in a good way?