title: javascript code does not run with x-tmpl or x-jQuery-tmpl template
body: <p>I Have this template for (xupload) blueimp plugin:  </p>
  
  <pre><code>&lt;script id="template-upload" type="text/x-tmpl"&gt;
  {% for (var i=0, file; file=o.files[i]; i++) { %}
  &lt;tr class="template-upload fade"&gt;
      &lt;td class="preview"&gt;&lt;span class="fade"&gt;&lt;/span&gt;&lt;/td&gt;
      &lt;td class="title"&gt;&lt;label&gt;Title: &lt;input type="text" name="title" required&gt;&lt;/label&gt;&lt;/td&gt;
      &lt;td class="name"&gt;&lt;span&gt;{%=file.name%}&lt;/span&gt;&lt;/td&gt;
      &lt;td class="size"&gt;&lt;span&gt;{%=o.formatFileSize(file.size)%}&lt;/span&gt;&lt;/td&gt;
      {% if (file.error) { %}
          &lt;td class="error" colspan="2"&gt;&lt;span class="label label-important"&gt;Error&lt;/span&gt; {%=file.error%}&lt;/td&gt;
      {% } else if (o.files.valid &amp;&amp; !i) { %}
          &lt;td&gt;
              &lt;div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"&gt;&lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt;&lt;/div&gt;
          &lt;/td&gt;
          &lt;td class="start"&gt;{% if (!o.options.autoUpload) { %}
              &lt;button class="btn btn-primary"&gt;
                  &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt;
                  &lt;span&gt;Start&lt;/span&gt;
              &lt;/button&gt;
          {% } %}&lt;/td&gt;
      {% } else { %}
          &lt;td colspan="2"&gt;&lt;/td&gt;
      {% } %}
      &lt;td class="cancel"&gt;{% if (!i) { %}
          &lt;button class="btn btn-warning"&gt;
              &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt;
              &lt;span&gt;Cancel&lt;/span&gt;
          &lt;/button&gt;
      {% } %}&lt;/td&gt;
  &lt;/tr&gt;
  {% } %}
  &lt;/script&gt;
  </code></pre>
  
  <p>I am trying to run this javascript code, it doesnt work, but when i run it inside console for firbug its work, what is the way to make it run when page load complete </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  jQuery(document).ready(function(){
      $("input[type=text]").focus(function(){
          alert('some text');
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>In my case,
  I am using yii extension (select2) this extension generate javascript select:</p>
  
  <pre><code>&lt;script id="template-upload" type="text/x-jQuery-tmpl"&gt;
  {% for (var i=0, file; file=o.files[i]; i++) { %}
  &lt;tr class="template-upload fade"&gt;
      &lt;td class="preview"&gt;
          &lt;span class="fade"&gt;&lt;/span&gt;
      &lt;/td&gt;
      {% if (file.error) { %}
          &lt;td class="error" colspan="2"&gt;&lt;span class="label label-important"&gt;Error&lt;/span&gt; {%=file.error%}&lt;/td&gt;
      {% } else if (o.files.valid &amp;&amp; !i) { %}
          &lt;td&gt;
              &lt;label&gt;&lt;?php echo CHtml::label('Keywords', 'keywords'); ?&gt;&lt;/label&gt;
              &lt;?php
                  echo CHtml::textField('tags',$selected,array('id'=&gt;'tags'));
                  $this-&gt;widget('ext.select2.ESelect2',array(
                    'selector'=&gt;'#tags',
                    'options'=&gt;array(
                      'tags'=&gt;$tags,
                      'width'=&gt;'400px;',
                    ),
                  ));
              ?&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;div class="progress progress-success progress-striped active"&gt;&lt;div class="bar" style="width:0%;"&gt;&lt;/div&gt;&lt;/div&gt;
          &lt;/td&gt;
          &lt;td class="start"&gt;{% if (!o.options.autoUpload) { %}
              &lt;button class="btn btn-primary"&gt;
                  &lt;i class="icon-upload icon-white"&gt;&lt;/i&gt;
                  &lt;span&gt;Start&lt;/span&gt;
              &lt;/button&gt;
          {% } %}&lt;/td&gt;
      {% } else { %}
          &lt;td colspan="2"&gt;&lt;/td&gt;
      {% } %}
      &lt;td class="cancel"&gt;{% if (!i) { %}
          &lt;button class="btn btn-warning"&gt;
              &lt;i class="icon-ban-circle icon-white"&gt;&lt;/i&gt;
              &lt;span&gt;Cancel&lt;/span&gt;
          &lt;/button&gt;
      {% } %}&lt;/td&gt;
  &lt;/tr&gt;
  {% } %}
  &lt;/script&gt;
  </code></pre>