与现有 HTML 绑定的视图

假设页面中包含以下 HTML:

<body>
    <div id="myPage">
    </div>
</body>

视图可以绑定到它:

var MyPageView = Backbone.View.extend( {
    "el": "#myPage",
    "template": _.template( "<p>This is my page.</p>" ),

    "initialize": function(){
        this.render();
    },

    "render": function(){
        this.$el.html( this.template() );
    }
} );

new MyPageView();

浏览器中的 HTML 现在将显示:

<body>
    <div id="myPage">
        <p>This is my page.</p>
    </div>
</body>