私はバックボーンから始めて、モデルが変更されるたびに警告する単純なビューを作成しようとしています。現在、ビューの初期化関数が呼び出されていますが、モデルが変更されたときにレンダリング関数が呼び出されていません (モデルが変更されています)。change イベントにバインドする 2 つの方法を試みました (initialize 関数と events プロパティ内)。明らかな何かが欠けているように感じます。
#jsonPreview id は html に存在します。
// Create the view
var JSONView = Backbone.View.extend({
initialize: function(){
this.bind("change", this.render);
},
render: function() {
alert("change");
},
events:
{
"change":"render"
}
});
// Create the view, and attach it to the model:
var json_view = new JSONView({ el: $("#jsonPreview"), model: documentModel });
前もって感謝します。