Skip to content

Instantly share code, notes, and snippets.

@TomoyaShibata
Last active August 29, 2015 14:10
Show Gist options
  • Save TomoyaShibata/38ab60754408e3ae6639 to your computer and use it in GitHub Desktop.
Save TomoyaShibata/38ab60754408e3ae6639 to your computer and use it in GitHub Desktop.
Backbone.View 間で共有したい、永続化しない Model。 "Mediator" という名付けがそもそも正しいのかは微妙なことと、こういう共有の方法で問題ないのかがちょっと不明。
this.Mediator.Model.Hoge = _.extend(Backbone.Model.prototype, {
title: 0,
name : 0,
// Viewは意図的に殺すので、監視ではなくViewがメソッドを呼ぶイメージ
changeTitle: function(title) {
this.title = title;
this.trigger('changedTitle');
},
// Viewは意図的に殺すので、監視ではなくViewがメソッドを呼ぶイメージ
changeName: function(name) {
this.name = name;
this.trigger('changedName');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment