我正在尝试收听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);