title: Knockout Mapping - Customize Create with Nested Objects
body: <p>I'm running into an issue with KnockoutJS's mapping plugin where I need to do the following:</p>
  
  <ol>
  <li>Customize the mapping creation of an object </li>
  <li>Customize the mapping creation of an array of nested objects from #1.</li>
  </ol>
  
  <p>In this <a href="http://jsfiddle.net/5cfa3/" rel="noreferrer">fiddle example</a> I am trying have the <em>children</em> properly mapped to their custom creation.  The expected result is that each of the <em>children</em> have the added <em>description</em> property.  From the fiddle, the result should read:</p>
  
  <ul>
  <li>Adam Smith</li>
  <li>Bob is 5 years old  </li>
  <li>Chris is 7 years old</li>
  </ul>
  
  <p>I can demonstrate the expected behaviour in this this <a href="http://jsfiddle.net/7Py7P/1/" rel="noreferrer">fiddle example</a>.  Notice that in this code I must have two data sets, with the first having an empty array of children objects.  The following line of code will cause the customized creation of child objects:</p>
  
  <pre><code>ko.mapping.fromJS(additionalData, parentMapping, viewModel);
  </code></pre>
  
  <p>Unfortunately, this requires both having empty initial <em>children</em> and mapping twice.  This is not acceptable as the code in reality has a much deeper hierarchy.</p>
  
  <p>In addition to the above, I've tried adding the following code in the parentMapping:</p>
  
  <pre><code>var mapping = { 'ignore': ["children"] };
  var innerModel = ko.mapping.fromJS(options.data, mapping);
  //for brevity
  innerModel.children = ko.mapping.fromJS(options.data.children, childMapping);
  </code></pre>
  
  <p>This has the effect of mapping the <em>children</em> objects on the initial mapping.  However, all subsequent mappings the <em>children</em> property is ignored.</p>
  
  <p>Is there a way to customize the creation of both a parent and child object with Knockout Mapping?</p>
  
  <p>Thank you.</p>