Vorlage wird nicht in backbone.js geladen (TypeError: Text ist undefiniert)

ich lernebackbone.js und ich bin so ziemlich am Anfang. Ich möchte eine Vorlage hinzufügenunterstreichen Template-Methode, aber es funktioniert nicht für mich. Ich habe nach diesem Fehler gesucht, konnte ihn aber nicht selbst beheben. Wie kann ich vorwärts gehen, wenn die Vorlage nicht angezeigt wird? Brauchen Sie Hilfe?

Hier ist der Code (dieser Code stammt aus addyosmanis Buch Backbone-Fundamentals):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>testing</title>
</head>
<body>
<script src="scripts/jquery.js"></script>
<script src="scripts/underscore.js"></script>
<script src="scripts/backbone.js"></script>
<script>


    var TodoView = Backbone.View.extend({
    tagName: 'li',
    // Cache the template function for a single item.
    todoTpl: _.template( $('#item-template').html() ),

    events: {
    'dblclick label': 'edit',
    'keypress .edit': 'updateOnEnter',
    'blur .edit': 'close'
    },

    // Re-render the titles of the todo item.

    render: function() {
    this.$el.html( this.todoTpl( this.model.toJSON() ) );
    this.input = this.$('.edit');
    return this;
    },

    edit: function() {
    // executed when todo label is double clicked
    },

    close: function() {
    // executed when todo loses focus
    },

    updateOnEnter: function( e ) {
    // executed on each keypress when in todo edit mode,
    // but we'll wait for enter to get in action
    }

    });


    var todoView = new TodoView();
    // logs reference to a DOM element that cooresponds to the view instance
    console.log(todoView.el);

Antworten auf die Frage(2)

Ihre Antwort auf die Frage