I'd like to find a way to initialize my app by the deviceready event I'm listening on.
I have this javascript files to be loaded:
//index.html
<head>
<script src="cordova.js">
<script src="require.js" data-main="main.js">
</head>
Now I'd like to call a function of main.js to start initializing my app, after the device really is ready. But I don't have any access because it's a requirejs module.
//index.html
<body>
<script>
function onDeviceReady() {
//main.js initialize my app
}
</script>
</body>
It'd be great to be able to call a function inside main.js like this:
//main.js
var myApp = {};
define(['app'],
function(app){
var init = function(){
app.run();
}
myApp.init = init;
}
);
Than back in my index.html:
<body>
<script>
function onDeviceReady() {
myApp.init();
}
</script>
</body>
I don't know if this'd work. How do you initialize your phonegap app using requirejs?