transitions
モデルの特定の属性 ( 、数値カウント)をリッスンしようとしています。ビューにthis.listenTo(this.model, 'change', _.bind(this.transition, this));
は、モデル変更イベント全体をリッスンするものがあります。ただし、以下は機能しません。
this.listenTo(this.model, 'change:transitions', _.bind(this.transition, this));
どの構文構造またはメソッド呼び出しを使用する必要がありますか? 別の BB メソッド呼び出しが必要な場合、違いは何ですか?
モデル:
define([
'underscore',
'backbone'
], function(_, Backbone) {
var RepresentationModel = Backbone.Model.extend({
initialize: function(options){
this.representationType = options.representationType;
this.previousRepresentationType = undefined;
this.transitions = 0;
},
transition: function(newRep){
this.set({
previousRepresentationType: this.representationType,
representationType: newRep,
transitions: this.transitions+1
});
}
});
return RepresentationModel;
});
リスニング ビュー:
...
this.listenTo(this.model, 'change', _.bind(this.transition, this));
...
通話ビュー: (リスニング ビューとは異なります)
var measureRepColl = StageCollection.get(hTrackCID).get('measures').models[0].get('measureRepresentations').get(measureRepCID).transition(newRepType);