Add an iterate() api call, that handles both Model and Collection.
Showing
1 changed file
with
7 additions
and
0 deletions
... | @@ -57,6 +57,13 @@ define(function(require) { | ... | @@ -57,6 +57,13 @@ define(function(require) { |
57 | } | 57 | } |
58 | } | 58 | } |
59 | }, | 59 | }, |
60 | iterate: function iterate(obj, callback, context) { | ||
61 | if (obj instanceof Model) { | ||
62 | obj.each(callback, context); | ||
63 | } else if (obj instanceof Collection) { | ||
64 | obj.each(callback, context); | ||
65 | } | ||
66 | }, | ||
60 | }; | 67 | }; |
61 | })(Backbone.Model, Backbone.Collection, 'add remove reset sort'); | 68 | })(Backbone.Model, Backbone.Collection, 'add remove reset sort'); |
62 | return adapter; | 69 | return adapter; | ... | ... |
-
Please register or sign in to post a comment