Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have not tried it but this may work.</p> <pre><code>var area_detail_model = Backbone.Model.extend({ defaults: { AreaGuid: null, AreaMapGuid: null } }); var area_map_model = Backbone.Model.extend({ defaults: { AreaMapGuid: null, DescriptionLevel: null } }); var area_model = Backbone.Model.extend({ defaults: { Area: new area_detail_model(), AreaMap: new area_map_model(), Connector: [] // can declare a model for connector also DependencyTags: [] // when using an array we can write bb_obj.get('Attr').ArrayItemName }, parse : function(response){ // at this point only area models exist, i.e from area collection each area model // is passed to this parse method response.Area = new area_model(response.Area); response.AreaModel = new area_map_model(response.AreaModel); return response; } }); var area_collection = Backbone.Collection.extend({ model: area_model, url: '/Areas', parse : function(response){ return response; // place a break point and check out the contents of response } }); var result_model = Backbone.Model.extend({ defaults: { Areas: new area_collection(), Id: null, Pricing: null, }, url: '/GetResults', parse : function(response){ response.Result.Areas = new area_collection(response.Result.Areas); return response.Result; // this will return only the Result section from your JSON } }); var result_obj = new result_model(); result_obj.fetch(); </code></pre> <p>So when the response is fetched then the result_model parse function will only pick Result from JSON and then we create a collection out the areas and the corresponding parse for each collection and method will be called in order. Let me know if it works.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload