title: How to create a custom binding for an observableArray
body: <p><em>Okay, the title of the question kind of suggests one solution I've been considering but here is my issue and I'm open to suggestions.</em></p>
  
  <p>I have a view model similar to this (although VASTLY simplified):</p>
  
  <pre><code>var viewModel = {
      items: ko.observableArray([new Person('fred'), new Person('Joe')]),
      name: ko.observable('hello world')  
  };
  
  function Person(name)
  {
      this.Name = ko.observable(name);
      this.Parent = ko.observable();
  }
  ko.applyBindings(viewModel);
  </code></pre>
  
  <p>Whenever a <code>Person</code> is added to items I want to automatically set it's <code>Parent</code> property to the thing it is being added to. (In my real application, this is a deeply hierarchical structure so I can't just hardcode the parent).</p>
  
  <p>I was considering writing a customer binding to make my own observableArray. Whenever anything was added to it, the custom binding would set the <code>Parent</code> property. I've looked at <a href="http://knockoutjs.com/documentation/custom-bindings.html" rel="nofollow">http://knockoutjs.com/documentation/custom-bindings.html</a> but this seems to only deal with normal observable properties.</p>
  
  <p><strong>So how would I do this or is there a better way of achieving this that I am missing?</strong></p>
  
  <p>Thanks!</p>