誰能告訴我爲什麼這段代碼會在var myview = new view();
處拋出一個「undefined不是函數」的錯誤?我一直在尋找所有,我很確定一切都是正確的。錯誤:「undefined不是函數」backbone.js
router = Backbone.Router.extend({
routes: {
'/': 'project'
},
project: function() {
projects = new models.Projects();
var view = Backbone.View.extend({
el: 'body' ,
render : function() {
$(this.el).empty().append(templates.Project({content : 'this works!' }));
return this;
}
});
console.log(view);
/*
* Output:
* { [Function]
extend: [Function],
augment: [Function],
toString: [Function],
register: [Function],
__super__:
{ bind: [Function],
unbind: [Function],
trigger: [Function],
tagName: 'div',
'$': [Function],
initialize: [Function],
render: [Function],
remove: [Function],
make: [Function],
delegateEvents: [Function],
_configure: [Function],
_ensureElement: [Function],
html: [Function],
toString: [Function],
template: [Function] } }
*/
var myview = new view();
this.send(myview, {collection: projects});
}
});
啊。我想我在設置el的時候並沒有選擇它。萬分感謝。 – thewildpendulum 2012-01-31 22:13:06
或'tagName:'body''也許? – Tjorriemorrie 2012-02-01 06:06:59