I load require.js with jQuery included as in my html:
<script data-main="requires" src="lib/require-jquery.js"></script>
The contents of my require.js:
require.config( {
paths: {
"jquery.mobile": "lib/jquery.mobile",
"jquery.mobile.router": "lib/jquery.mobile.router"
},
shim: {
"jquery.mobile" : {
"exports": "$.mobile"
},
"jquery.mobile.router": {
"deps": [ "jquery.mobile" ],
"exports": "$.mobile.Router"
}
}
} );
require(["jquery.mobile.router" ], function() {
require(["router"]);
} );
And in my router.js, I create a new instance of the jquery mobile router plugin :
router = new $.mobile.Router(...);
Which gives me this error:
Uncaught TypeError: undefined is not a function
When I print $ and $ .mobile, they are both defined, just $ .mobile.Router is undefined.
What have I done wrong here?
source
share