You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Occasionally, views need more fine-grained notification than the coarse-grained change event that usually causes the view to make a complete refresh. For example, a PersonView might want to know only when the PersonModel's name changes and only update the visible name in the display.
The plugin implementation would be
(function() {
var original = maria.Model.prototype.dispatchEvent;
return function(evt) {
var type = evt.type;
while (type) {
evt.type = type;
original.call(this, evt);
type = type.replace(/\:?[^\:]+$/, '');
}
};
}());
With this plugin, a model can have just
setName: function(name) {
name = '' + name;
if (this._name !== name) {
this.name = name;
this.dispatchEvent({type:'change:name'});
}
}
which is equivalent to the following without the plugin
setName: function(name) {
name = '' + name;
if (this._name !== name) {
this.name = name;
this.dispatchEvent({type:'change:name'});
this.dispatchEvent({type:'change'});
}
}
When using the plugin, a view that needs fine-grained control will use different modelActions object, for example,
Occasionally, views need more fine-grained notification than the coarse-grained
change
event that usually causes the view to make a complete refresh. For example, a PersonView might want to know only when the PersonModel's name changes and only update the visible name in the display.The plugin implementation would be
With this plugin, a model can have just
which is equivalent to the following without the plugin
When using the plugin, a view that needs fine-grained control will use different
modelActions
object, for example,The text was updated successfully, but these errors were encountered: