When a collection is fetched, forward any collectionEvents from it to
the change:$key handler on it's container.
Showing
1 changed file
with
13 additions
and
1 deletions
... | @@ -37,7 +37,19 @@ define(function(require) { | ... | @@ -37,7 +37,19 @@ define(function(require) { |
37 | } else { | 37 | } else { |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | return obj.get(keypath); | 40 | var value = obj.get(keypath); |
41 | if (value instanceof Collection) { | ||
42 | var listener = function() { | ||
43 | var currentValue = obj.get(keypath); | ||
44 | if (value !== currentValue) { | ||
45 | obj.stopListening(value, collectionEvents, listener); | ||
46 | return; | ||
47 | } | ||
48 | obj.trigger('change:' + keypath, obj, currentValue); | ||
49 | }; | ||
50 | obj.listenTo(value, collectionEvents, listener); | ||
51 | } | ||
52 | return value; | ||
41 | }, | 53 | }, |
42 | set: function set(obj, keypath, value) { | 54 | set: function set(obj, keypath, value) { |
43 | if (obj instanceof Model) { | 55 | if (obj instanceof Model) { | ... | ... |
-
Please register or sign in to post a comment