I'm creating a Phonegap app. I'm using Require.js and am implementing Push Notification. In my index.html file I have:
<script data-main="js/app" src="js/require.js"></script>
<script type="text/javascript" src="js/app/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
The app.js defines the base url for Require.js modules and initiates the router. Index.html defines the "deviceready" listener. The problem is that within index.js, I need to have accress to Require.js modules, such as Jquery. But for example, in index.js, if I do:
initialize: function() {
require(["jquery"], function () {
});
},
I get the error:
Uncaught Error: Script error for: jquery
http://requirejs.org/docs/errors.html#scripterror at file:///android_asset/www/js/require.js:8
Uncaught Error: Load timeout for modules: backbone
http://requirejs.org/docs/errors.html#timeout at file:///android_asset/www/js/require.js:8
I think this is because index.js is called whilst app.js is still setting up paths etc. I need index.js to execute after app.js is finished. I CANNOT use:
$(document).ready(function() {
app.initialize();
});
because Jquery is loaded as a module so will throw an error. I also cannot load index.js as a module because of a problem I wrote about in another SO question here.
Any ideas what I can do?