BrainLikeADullPencil
BrainLikeADullPencil

Reputation: 11673

including a partial in ember

At about the 17:23 minute of the EmberJs introductory tutorial in the Ember guides http://emberjs.com/guides/, the tutorial author includes a partial in a template, using the format {{partial 'post/edit'}} to call the partial and indicate where it should be included, and then he gives the partial that's included an id in this style

id="post/_edit"

I'm copying that pattern in this code but the partial is not included in the list of courts. Is there something that I'm doing wrong? As far as I understand, I only need to indicate in Handlebars that I'm including a partial and not do anything in an Ember view or controller to make it work.

<script type="text/x-handlebars" id="courts">

  <div class='span4'>
      {{#each item in model}}
      <li> {{#link-to 'court' item}}
      {{ item.name }} 
      {{ partial 'courts/blah'}}
      {{/link-to }}</li>
    {{/each}}

         </ul>
  </div>

  <div class="span4 offset4">
   {{ outlet}}
   </div>

</script>

 <script type="text/x-handlebars" id="courts/_blah">
    This is a partial  blah blah
 </script>

Code from EmberJS tutorial.

  <script type="text/x-handlebars" id="post">
    {{#if isEditing}}
      {{partial 'post/edit'}}
      <button {{action 'doneEditing'}}>Done</button>
    {{else}}
      <button {{action 'edit'}}>Edit</button>
    {{/if}}


  </script>

  <script type="text/x-handlebars" id="post/_edit">
    <p>{{input type="text" value=title}}</p>
    <p>{{input type="text" value=excerpt}}</p>
    <p>{{textarea value=body}}</p>
  </script>

Upvotes: 1

Views: 721

Answers (1)

Jeremy Green
Jeremy Green

Reputation: 8594

Usually you want to use data-template-name instead of id for naming your templates.

<script type="text/x-handlebars" data-template-name="application">
  <!-- Stuff goes here. -->
</script>

Upvotes: 1

Related Questions