我正在将单页应用程序转换为backbone.JS。下面的视图使用 body 标记作为它的 tagName - 即,我希望视图占据页面的全部内容。我不想使用容器 div 或其他技巧。
var ThingView = Backbone.View.extend({
tagName : "body",
...
// Show the HTML for the view
render : function() {
console.log('Displaying thing')
$(this.el).append('<h1>test</h1>');
console.log('finished')
console.log($(this.el))
return this; // For chaining
渲染时,我看到
finished
[
<body>
<h1>test</h1>
</body>
]
但是在我检查 DOM 之后,正文不再有文本。