Download:
child 11:4232194a24ca
parent 9:f3aad748ea73
10:9af1bfa5800d
Anton Shestakov <engored@ya.ru>, Thu, 13 Dec 2012 04:02:52 +0900
Changing model attribute used in shard filter works as expected.

1 файлов изменено, 15 вставок(+), 3 удалений(-) [+]
backbone.shard.js file | annotate | diff | comparison | revisions
--- a/backbone.shard.js Thu Dec 13 03:19:14 2012 +0900
+++ b/backbone.shard.js Thu Dec 13 04:02:52 2012 +0900
@@ -16,18 +16,30 @@
this._collection
.on('all', function(event, model) {
- if (/^change/.test(event) && this._filter(model) && this.models.indexOf(model) != -1) {
+ if (event == 'change') {
+ if (this._filter(model) && _(this.models).contains(model)) {
+ this.trigger.apply(this, arguments);
+ }
+ if (this._filter(model) && !_(this.models).contains(model)) {
+ this.models.push(model);
+ this.trigger('add', model);
+ }
+ if (!this._filter(model) && _(this.models).contains(model)) {
+ this.models = _.without(this.models, model);
+ this.trigger('remove', model);
+ }
+ } else if (/^change:/.test(event) && this._filter(model) && _(this.models).contains(model)) {
this.trigger.apply(this, arguments);
}
}, this)
.on('add', function(model) {
- if (this._filter(model) && this.models.indexOf(model) == -1) {
+ if (this._filter(model) && !_(this.models).contains(model)) {
this.models.push(model);
this.trigger('add', model);
}
}, this)
.on('remove', function(model) {
- if (this._filter(model) && this.models.indexOf(model) != -1) {
+ if (this._filter(model) && _(this.models).contains(model)) {
this.models = _.without(this.models, model);
this.trigger('remove', model);
}