title: JQuery doesn't locate DOM elements when using Durandal's compose
body: <p>I've recently ported my company's project to Durandal using Knockout and JQuery. Straight to the problem: I need to initialize JQuery UI's datepicker using two HTML inputs. JQuery, however, is unable to locate the inputs when I do this:</p>
  
  <p><strong>view:</strong></p>
  
  <pre><code>&lt;div data-bind="if: !CurrentUser()"&gt;
      &lt;h1 data-bind="html: DisplayName"&gt;&lt;/h1&gt;
  
      &lt;div data-bind="compose: 'users/_UsersList.html'"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div data-bind="with: CurrentUser(), visible: CurrentUser()"&gt;
      &lt;h1&gt;User detail&lt;/h1&gt;
  
      &lt;div data-bind="compose: 'users/_UserDetail.html'"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>viewmodel - SelectUser() function is called when a user is selected in the first div, then the second div and also users/_UserDetail.html is loaded:</strong></p>
  
  <pre><code>users.SelectUser = function (user) {
      users.CurrentUser(user);
  
      /* ... */
  
      $(function () {
          $("#datepickerFrom").datetimepicker({
              dateFormat: "d. m. yy",
              timeFormat: "HH:mm:ss",
              defaultDate: null
          });
  
          $("#datepickerTo").datetimepicker({
              dateFormat: "d. m. yy",
              timeFormat: "HH:mm:ss"
          });
      });
  }
  </code></pre>
  
  <p><strong>The important part of _UserDetail.html</strong></p>
  
  <pre><code>&lt;div class="control-group"&gt;
      &lt;label class="control-label"&gt;Active from&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;input type="text" data-bind="value: ActiveFrom" id="datepickerFrom" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="control-group"&gt;
      &lt;label class="control-label"&gt;Active to&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;input type="text" data-bind="value: ActiveTo" id="datepickerTo" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Then the two HTML inputs come as undefined. If I change the <code>div</code> with the <code>compose</code> binding to the actual users/_UserDetail.html content, it works just fine, but then the view quickly becomes a mess - the html file isn't exactly small. If someone could point me to the right direction, I would be grateful. Thanks!</p>