2013-09-11 1 views
0

В принципе у меня есть шаблон значка, который имеет соответствующую модель значков. Каждый значок имеет (принадлежит) наставнику. Однако, когда я загружаю шаблон, вызывается модель значка и отображаются данные. Если я проверю сетевые запросы, приложение запрашивает правильного наставника, но оно не отображается в шаблоне. Любая идея, почему это будет происходить?Почему связанная модель не загружается в шаблон, даже если запрос возвращает правильную связанную модель?

Знак

App.Badge = DS.Model.extend({ 
    'category': DS.belongsTo('category'), 
    'title': attr('string'), 
    'type': attr('string'), 
    'ord': attr('number'), 
    'short_description': attr('string'), 
    'full_description': attr('string'), 
    'mentor': DS.belongsTo('employee' , { async: true }), 
    'parent':DS.belongsTo('badge'), 
    'icon': attr('string'), 
    'required': attr('boolean'), 
    'signoff_role': attr('string'), 
    'created_at': attr('string'), 
    'updated_at': attr('string'), 
    'resources': DS.hasMany('resource', { async: true }), 
    'quiz': DS.belongsTo('quiz', { async: true }) 
}); 

Сотрудник

App.Employee = DS.Model.extend({ 
    'badge': DS.belongsTo('badge', { async:true }), 
    'employee_preferred_name': DS.attr('string'), 
    'email': DS.attr('string'), 
    'phone': DS.attr('string') 
}); 

знак Route

App.BadgeRoute = Ember.Route.extend({  

    model: function(params) { 
     return this.store.find('badge',params.badge_id); 
    }, 
    renderTemplate: function() { 
    this.render('categories',{outlet: "categoriesList"}); 
    this.render('category',{outlet: "badgeList"}); 
    this.render('badge',{outlet: "body"}); 
    this.render('badge/index',{outlet:'badgeBody',into: "badge"}) 
    }  

}); 

Знак Шаблон

<div class="row"> 
    <div class="col col-lg-12"> 
    {{! Section }} 
     <h3>Basic Info</h3> 
     <hr> 
     {{! Tag Line }} 
     <div class="row" style="margin-bottom:30px"> 
      <div class="row page-header-title"> 
       <div class="col col-lg-11"> 
        <h4>Tag Line</h4> 
       </div> 
       {{#view App.EditTagLineView}} 
        <h4 {{bindAttr class=":glyphicon isEditingTagLine:glyphicon-nothing:glyphicon-pencil :edit-button"}}></h4> 
       {{/view}} 
      </div> 
      <div class="container" style="margin-top:1em;"> 
       {{#if short_description}} 
        {{short_description}} 
       {{else}} 
        <span class="text-muted">No Tag Line provided</span> 
       {{/if}} 
      <div> 
     </div> 
     {{! Description }} 
     <div class="row"> 
      <div class="row page-header-title"> 
       <div class="col col-lg-11"> 
        <h4>Description</h4> 
       </div> 
       {{#view App.EditDescriptionView}} 
        <h4 {{bindAttr class=":glyphicon isEditingTagLine:glyphicon-nothing:glyphicon-pencil :edit-button"}}></h4> 
       {{/view}} 
      </div> 
      <div class="container" style="margin-top:1em;"> 
       {{#if full_description}} 
        {{markdown full_description}} 
       {{else}} 
        <span class="text-muted">No description provided</span> 
       {{/if}} 
      <div> 
     </div> 
     {{! Mentor }} 
     <div class="row"> 
      <div class="row page-header-title"> 
       <div class="col col-lg-11"> 
        <h4>Mentor</h4> 
       </div> 
       {{#view App.EditDescriptionView}} 
        <h4 {{bindAttr class=":glyphicon isEditingTagLine:glyphicon-nothing:glyphicon-pencil :edit-button"}}></h4> 
       {{/view}} 
      </div> 
      <div class="container" style="margin-top:1em;"> 
      {{#if mentor}}  

       Name:{{mentor.employee_preferred_name}}<br> 
       Email: {{mentor.email}}<br> 
       Phone: {{mentor.phone}} 
      {{else}} 
      wow 
      {{/if}}  

      <div> 
     </div> 
    </div> 
</div> 
{{!-- 
<div class="row"> 
    <div class="col col-lg-12"> 
     <h3>Basic Info</h3> 
     <hr> 
     <div class="row page-header-title"> 
      <div class="col col-lg-11"> 
       <h4>Tag Line</h4> 
      </div> 

      {{#view App.EditTagLineView}} 
       <h4 {{bindAttr class=":glyphicon isEditingTagLine:glyphicon-nothing:glyphicon-pencil :edit-button"}}></h4> 
      {{/view}} 
     </div> 
     <p> 
      {{#if isEditingTagLine}}  

       {{view Ember.TextField valueBinding="short_description" class="form-control" style="padding-top:10px"}} 
       <hr> 
       <button {{action saveTagLine}} class="btn btn-success">Save</button>  

      {{else}}  

       {{#if short_description}}  

        {{short_description}}  

       {{else}}  

        No tag line provided  

       {{/if}}  

      {{/if}} 
     </p> 
     <div class="row page-header-title"> 
     <div class="col col-lg-11"> 
      <h4> 
       Description 
      </h4> 
     </div> 
      {{#view App.EditDescriptionView}} 
       <h4 {{bindAttr class=":glyphicon isEditingDescription:glyphicon-nothing:glyphicon-pencil :edit-button"}}></h4> 
      {{/view}} 
     </div> 
     <p> 
      {{#if isEditingDescription}} 
       {{view Ember.TextArea valueBinding="full_description" class="form-control" rows="6"}} 
       <hr> 
       <button {{action saveDescription}} class="btn btn-success">Save</button> 
       <a href="http://daringfireball.net/projects/markdown/syntax" target="new" class="btn btn-link"><span class="glyphicon glyphicon-info-sign"></span> More on Markdown </a> 
      {{else}} 
       {{#if full_description}} 
        {{markdown full_description}} 
       {{else}} 
        <span class="text-muted">no description provided</span> 
       {{/if}} 
      {{/if}} 
      </p> 
    </div> 
</div> 
<div class="row page-header-title" > 
    <div class="col col-lg-11"> 
     <h4> 
      Mentor 
     </h4> 
    </div> 
    <div class="col col-lg-1"> 
    <h4 class="glyphicon glyphicon-pencil edit-button"></h4> 
    </div> 
</div> 
     {{#if mentor}} 
     <address> 
      {{log mentor}} 
      <strong> {{mentor.employee_preferred_name}}</strong> 
      <br> 
      {{#if mentor.phone}} 
      <abbr title="Phone">P:</abbr> {{mentor.phone}} <br> 
      {{else}} 
      <small> no phone number provided </small> <br> 
      {{/if}} 
      {{#if mentor.email}} 
      <abbr title="Email">E:</abbr> {{mentor.email}} 
      {{else}} 
      <small> no email number provided </small> <br> 
      {{/if}} 
     </address>  

     {{/if}} 
</div> 
</div>  

--}} 

ответ

0

могли бы вы предоставить маршрутизатор и имя шаблона значка вы определили в тэге? Было бы очень полезно.

Я бы предложил переименовать маркер вашего знака в App.BadgeIndexRoute и использовать шаблон под своим именем badge/index.

У меня недавно была проблема, и причина в том, что я не использовал правильный маршрут и шаблон.

Смежные вопросы