title: KockoutJS External Template Engine and custom binding
body: <p>I use in my application <a href="https://github.com/fazzamar/Knockout.js-External-Template-Engine" rel="nofollow noreferrer">KockoutJS External Template Engine</a> to be able to load external templates files(so i can use them again in many pages). It's works good and i could use templates in another folder and data displayed correctly  </p>
  
  <p>My problem is that i want to call some function after my template is fully rendered and i used this <a href="https://stackoverflow.com/questions/17552042/knockoutjs-execute-callback-after-foreach-finishes-rendering"><strong>solution</strong></a> with custom bindings (thanks to @RP Niemeyer).  </p>
  
  <p>The problem is that custom binding is executed before the template html is fully rendered when using external template file.  </p>
  
  <p>But using template which is existed inside my html page the custom binding is executed after the template html is fully rendered.<br>
  My template:</p>
  
  <pre><code>&lt;script type="text/html" id="report-template"&gt;
      &lt;li&gt;
          &lt;a href="#" data-bind="text: Name, click: $root.ReportsViewModel.ShowParameters"&gt;&lt;/a&gt;
          &lt;ul data-bind="template: { name: 'report-template', foreach: childItems }"&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>and that's how i call my custom binding <code>jsTree</code></p>
  
  <pre><code>&lt;div id="reports-tree"&gt;
      &lt;ul data-bind="template: { name: 'report-template', foreach: $root.ReportsViewModel.Reports }, jsTree: $root.ReportsViewModel.Reports"&gt;&lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and that's my custom binding code:</p>
  
  <pre><code>ko.bindingHandlers.jsTree = {
      update: function (element, valueAccessor) {
          var reports = ko.utils.unwrapObservable(valueAccessor());
          if (reports.length &gt; 0) {
              $(element).parent().jstree({
                  "themes": {
                      "theme": "default",
                          "dots": false,
                          "icons": true,
                          "utl": "/jstree-style.css"
                  },
                      "plugins": ["themes", "html_data"]
              });
          }
      }
  }
  </code></pre>