I'm sitting on my first attempt on implementing Require.js and although I'm trying to follow both of these tutorials (here and here) I don't quite get it to work. This is what I have so far:
Inside my index file:
<script type="text/javascript" data-main="../js/main" src="../js/libs/require/require.js"></script>
Inside main.js
require.config({ baseUrl: "../js/",
paths: {
"jq-loader": "libs/jquery/jquery",
"jqm-loader": "libs/jquery-mobile/jquery-mobile",
"someplug": "libs/someplug/somplug",
}
});
// define app and dependencies??? - not sure what goes here? All plugins I'm using?
require(['app','order!libs/jquery/jquery', 'order!libs/jquery-mobile/jquery-mobile'],
function(App){
App.start();
});
Inside jquery.js
define([ 'order!libs/jquery/jquery.min' ], function(){ return $; });
Inside jquery.js (which is depending on Jquery)
// ERROR here in "mobile" being undefined
define(['order!libs/jquery-mobile/jquery-mobile.min'], function(){ return mobile; });
And app.js
define([ 'jq-loader', 'jqm-loader'], function($, mobile){
var start = function() {
$(document).ready(function() {
alert("Hello world!");
})
}
return {"start":start};
});
I'm happy I have made it so far, but would really like to see everything clicking. Right now, I'm getting an error mobile is not defined inside my jquery-mobile.js file. I guess because Jquery-Mobile does not really belong where it is...
Can someone shed some light? Thanks a lot!
EDIT:
Here is a link to my sample setup