0

基本上我有一个徽章模板,它有一个相应的徽章模型。每个徽章都有(属于)一位导师。但是,当我加载模板时,会调用 Badge 模型并显示它的数据。如果我检查网络请求,应用程序正在请求正确的导师,但它没有显示在模板上。知道为什么会发生这种情况吗?

徽章

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')
});

徽章路线

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>    

--}}
4

1 回答 1

0

Could you provide your router and the name of the badge template you defined in the script tag? It would be very helpful.

I would suggest to rename your Badge Route to App.BadgeIndexRoute and use a template called badge/index.

I've had an issue recently and the reason was that I was not using the correct route and template.

于 2013-09-14T15:13:08.570 回答