对象渲染没有方法“应用”
我收到错误:
对象渲染没有方法适用于下面的代码。
  可能是什么原因?  该HTML页面不包含除JavaScript的链接以外的任何代码。 
  我应该怎么做才能消除错误? 
(function($) {
    window.Book = Backbone.Model.extend({});
    window.Library = Backbone.Collection.extend({
        model: Book
    }); // end of Collection
    window.LibraryView = Backbone.View.extend({
        el: $('body'),
        events: {
            'click button#btn_add': 'btn_add'
        },
        initialize: function() {
            $(this.el).append("View initialized");
            _.bindAll(this, 'render', 'btn_add');
            this.collections = new Library();
            this.collections.bind('add', 'render', this);
            this.startingDisplay();
        },
        startingDisplay: function() {
            $(this.el).append("<input type='text' id='t1' /><button id='btn_add'>Add</button>");
        },
        btn_add: function() {
            book = new Book({
                title: "first"
            });
            alert("Name : " + book.get('title'));
            this.collections.add(book);
        },
        render: function() {
            alert("render called");
        },
    }); // end of LibraryView
    libraryview = new LibraryView();
})(jQuery);
  您没有使用正确的语法来绑定add收集事件。  使用: 
// this.collections.bind('add', 'render', this);
this.collections.bind('add', this.render, this);
第二个参数预计是一个回调(一个函数)。
DEMO
链接地址: http://www.djcxy.com/p/58661.html上一篇: Object render has no method 'apply'
下一篇: How does a debugger like gdb work to set a breakpoint through JTAG?
