undefined is not a function error in backbone

I have a html template which includes backbone code.i am a newbiw to backbone.whenever i try to run the code it shows an uncaught error undefined is not a function error.Please help.

  <!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://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.0/backbone-min.js"></script>



        <script type="text/javascript">
        (function($){
        //ListView class: Our main app view.

      var ListView = Backbone.View.extend({
        el: $('body'), // attaches `this.el` to an existing element.

    //initialize(): Automatically called upon instantiation. Where you make all types of bindings, excluding UI events, such as clicks, etc.

        initialize: function(){
          _.bindAll(this, 'render'); // fixes loss of context for 'this' within methods

           this.render(); // not all views are self-rendering. This one is.
        },

    //render(): Function in charge of rendering the entire view in this.el. Needs to be manually called by the user.

        render: function(){
          $(this.el).append("<ul> <li>hello world</li> </ul>");
        }
      });

    //listView instance: Instantiate main app view.

      var listView = new ListView();
        })(jQuery);
        </script>
      </body>
      </html>

Answers


The problem is caused by an old versions of underscore.js. After changing it to a newer version the error is gone and your code works.

http://jsfiddle.net/3dH24/4/

Underscore version used in demo:

//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js

P.S. you can see the files imported (in HEAD), if you look at the External Resources in the left accordion menu on jsFiddle.


Need Your Help

Django Tutorial - TemplateDoesNotExist at /polls/

python django

I have tried to get this to work a million times. I have lef it alone for a week and come back. I have Googled and read every post pertaining to this. I have let insecure morons belittle in messages

Removing All Nulls From Collections

c# .net collections

I'm having to deal with collections of data being thrown at my application from data sources out of my control. Some of these collections contain nulls which I would prefer to filter out as soon a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.