title: Show a toolbar in shell header that is bound to the current viewmodel in Durandal
body: <p>I'm trying to achieve a context dependent toolbar in the header of my shell. The goal is to have the page-specific toolbar view bound to current viewmodel, not the shell or a separate toolbar vm. (Kinda like @RenderSection in Layout using asp.net Razor syntax). </p>
  
  <p>When the current viewmodel is activated, I trigger a message with an object literal that describes the toolbar view location and that it's viewmodel should be <code>this</code>.</p>
  
  <pre><code>    function activate() {
          app.trigger('toolbar', { view: 'views/ediToolbar', model: this });
      }
  </code></pre>
  
  <p>The shell correctly listens and updates the activeToolbar binding, but in the process calls the <code>activate</code> method on vm creating an infinite loop. Is there a way to prevent the infinite loop or am I going about this completely the wrong way?</p>
  
  <p>shell.js </p>
  
  <pre><code>activeToolbar = ko.observable();
  
  function activate() {
      // normal setup stuff
      app.on('toolbar', function(data) {
          activeToolbar(data)
      }
  }
  </code></pre>
  
  <p>shell.html</p>
  
  <pre><code>&lt;div data-bind="if: activeToolbar" class="toolbar"&gt;
      &lt;!-- ko compose: { view: activeToolbar().view, model: activeToolbar().model } --&gt;
      &lt;!-- /ko --&gt;
  &lt;/div&gt;
  </code></pre>