I am completely new to Backbone JS. I thought I could solve this minor problem by myself but I can't figure why I am still getting this error:
Uncaught ReferenceError: Backbone is not defined
when trying to extend a Backbone.Model. backbone.js
is called before the script that uses it so I don't get it.
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/backbone.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<title></title>
</head>
<body>
</body>
</html>
My external file main.js
(function($) {
window.Doc = Backbone.Model.extend({
defaults : {
id : '???',
title : 'Le titre de mon modèle',
text : 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer varius ipsum nec porta dignissim. Donec a elementum magna. Donec sagittis magna eu nulla ullamcorper dictum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam volutpat felis vehicula, congue mi at, lobortis dolor.',
keywords : 'lorem ipsum dolor sit amet'
},
initialize : function Doc() {
console.log('Doc Constructor');
}
});
})(jQuery);
I also get the following error coming from backbone.js:219
Uncaught TypeError: Cannot call method 'each' of undefined
304 Not Modified
status. – D4V1Dunderscore.js
. It works now! Thanks! – D4V1D