Gabriel
Gabriel

Reputation: 439

Error: Backbone is not defined

I am trying to run a very simple an basic sample of a backbone model that is found on a tutorial for learning the library.

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.string/2.3.3/underscore.string.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>

<script>

User = Backbone.Model.extend({
    initialize: function() {
        alert("Backbone model initialized");
    }
});

var user = new User;

</script>

But on the console there are 2 errors :

Uncaught TypeError: Object # has no method 'each' on the backbone-min file

Uncaught ReferenceError: Backbone is not defined

And is not working. Would yo please help me understand what am I doing wrong?

Upvotes: 1

Views: 985

Answers (1)

Vahe Khachikyan
Vahe Khachikyan

Reputation: 241

You're not loading the full underscore library. Replace the second script tag with the following:

<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>

Upvotes: 1

Related Questions