Dark Knight
Dark Knight

Reputation: 503

Backbone Undefined is not a function error

I'm learning backbone and I'm trying to execute this sample code to get the feel.

http://backbonetutorials.com/what-is-a-view/

My code:

  <!DOCTYPE html>
  <html>
  <head>
    <meta charset="utf-8">
    <title>hello-backbonejs</title>
  </head>
  <body>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js"></script>
    <script src="http://backbonejs.org/backbone.js"></script>
    <script type="text/javascript">
Rocky = Backbone.Model.extend({
  initialize: function(){
    console.log('hello world');
  }
});
</script>
  </body>
  </html>

I get this error.

Uncaught type error: Undefined is not a function!

What did I do wrong? I was just trying to print and see if it's printed on my console!

Thanks, R

Upvotes: 1

Views: 68

Answers (1)

dashtinejad
dashtinejad

Reputation: 6253

Your underscore.js version is too old. Try to use the new version (1.7):

<script src="http://underscorejs.org/underscore.js"></script>

Upvotes: 2

Related Questions