Show More
@@ -210,6 +210,15 b' function(WidgetManager, _, Backbone){' | |||||
210 | // Replace models with model ids recursively. |
|
210 | // Replace models with model ids recursively. | |
211 | if (value instanceof Backbone.Model) { |
|
211 | if (value instanceof Backbone.Model) { | |
212 | return value.id; |
|
212 | return value.id; | |
|
213 | ||||
|
214 | } else if ($.isArray(value)) { | |||
|
215 | var packed = []; | |||
|
216 | var that = this; | |||
|
217 | _.each(value, function(sub_value, key) { | |||
|
218 | packed.push(that._pack_models(sub_value)); | |||
|
219 | }); | |||
|
220 | return packed; | |||
|
221 | ||||
213 | } else if (value instanceof Object) { |
|
222 | } else if (value instanceof Object) { | |
214 | var packed = {}; |
|
223 | var packed = {}; | |
215 | var that = this; |
|
224 | var that = this; | |
@@ -217,6 +226,7 b' function(WidgetManager, _, Backbone){' | |||||
217 | packed[key] = that._pack_models(sub_value); |
|
226 | packed[key] = that._pack_models(sub_value); | |
218 | }); |
|
227 | }); | |
219 | return packed; |
|
228 | return packed; | |
|
229 | ||||
220 | } else { |
|
230 | } else { | |
221 | return value; |
|
231 | return value; | |
222 | } |
|
232 | } | |
@@ -224,13 +234,22 b' function(WidgetManager, _, Backbone){' | |||||
224 |
|
234 | |||
225 | _unpack_models: function(value) { |
|
235 | _unpack_models: function(value) { | |
226 | // Replace model ids with models recursively. |
|
236 | // Replace model ids with models recursively. | |
227 |
if (value |
|
237 | if ($.isArray(value)) { | |
|
238 | var unpacked = []; | |||
|
239 | var that = this; | |||
|
240 | _.each(value, function(sub_value, key) { | |||
|
241 | unpacked.push(that._unpack_models(sub_value)); | |||
|
242 | }); | |||
|
243 | return unpacked; | |||
|
244 | ||||
|
245 | } else if (value instanceof Object) { | |||
228 | var unpacked = {}; |
|
246 | var unpacked = {}; | |
229 | var that = this; |
|
247 | var that = this; | |
230 | _.each(value, function(sub_value, key) { |
|
248 | _.each(value, function(sub_value, key) { | |
231 | unpacked[key] = that._unpack_models(sub_value); |
|
249 | unpacked[key] = that._unpack_models(sub_value); | |
232 | }); |
|
250 | }); | |
233 | return unpacked; |
|
251 | return unpacked; | |
|
252 | ||||
234 | } else { |
|
253 | } else { | |
235 | var model = this.widget_manager.get_model(value); |
|
254 | var model = this.widget_manager.get_model(value); | |
236 | if (model) { |
|
255 | if (model) { |
General Comments 0
You need to be logged in to leave comments.
Login now