1

したがって、Backbone.js から拡張されたオブジェクトがいくつかあります。

var MyModel = Backbone.Model.extend({});
var modelInstance = new MyModel();
var MyModelView = Backbone.View.extend({});

そして、モデルを対応するビューにバインドする方法を見つけようとしています。バックボーンでのデータバインディングの処理方法は?

4

1 に答える 1

3

ビューを作成するときに、モデル インスタンスをビューに渡します。

var modelView = new MyModelView({model: modelInstance})

ドキュメントから:

When creating a new View, the options you pass — after being merged into any default 
options already present on the view — are attached to the view as this.options 
for future reference. There are several special options that, if passed, will be 
attached directly to the view: model, collection, el, id, className, tagName and attributes.
于 2013-03-30T16:22:10.363 に答える