Reputation: 99990
Using RequireJS and Backbone, is it possible to avoid the classic call
$(document).ready(function () {
});
I just want to know if I can avoid it, if I am using RequireJS and Backbone. How is it possible to avoid that call?
Upvotes: 0
Views: 92
Reputation: 790
Yes, actually you don't need this using require.js
1st
<script data-main="main.js" src="path/require.js"></script>
On main file you could have something like this:
require.config({
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: [
'underscore',
'jquery'
],
exports: 'Backbone'
}
},
paths: {
jquery : 'path/jquery',
underscore : 'path/underscore',
backbone : 'path/backbone'
}
});
require(
[
'backbone',
'router'
],
function (Backbone, Router) {
var router = new Router();
}
);
Upvotes: 1