根据我的说法,尽管一切都是正确的,我的加载更多按钮仍未显示

时间:2015-10-05 15:04:21

标签: javascript html meteor

HTML端代码

<template name="profPageAuthorSubmit">
    <div>
        <ul style="list-style-type:none" class="pclProf">
            <li><img id="profilePagePic" src="{{profilePagePicture}}"><span class="username">{{authorSubmit}}</span></li>
            <li class="accesories">{{a}} Poems</li>
            <li class="accesories">{{b}} Short stories</li>
            <li class="accesories">{{c}} Followers</li>
            <li class="accesories">{{d}} Followings</li>
        </ul>
    </div>
    <div>
    <ul style="list-style-type:none" class="pcl">
    {{#each Contents}}
      <li class="p">
        <p class="bucket">  
          <li><span class="contentType">{{type}}</span></li>
          <li><span class="titleBody"><strong>{{{title}}}</strong></span></li>
          <li><a href="/user/{{createdBy}}"><img class="authorPic" src="{{authorPhoto}}"><span class="authorName">{{author}}</span></a></li>
          <li><span class="createdAtTime">Written at {{createdAt}}</span></li>  
          <li class="contentMain">{{{content}}}</li>
          {{>contentEssentials}}
          {{#if editing}}
            {{>contentEdit}}
          {{/if}}
          {{>commentsTemp}}
        </p>
      </li>
    {{/each}}
    **{{#if nextPath}}
        <a href="{{nextPath}}" class="btn btn-default load-more">Load more</a>
          {{#unless ready}}
            {{> spinner}}
          {{/unless}}
    {{/if}}**
    </ul>
    </div>
</template>

客户端代码

profileController= RouteController.extend({
  template: 'profPageAuthorSubmit',
  increment: 10,
  contentsLimit: function() {
    return parseInt(this.params.contentsLimit) || this.increment;
  },
  findOptions: function() {
    return {sort: {createdAt: -1}, limit: this.contentsLimit()};
  },
  subscriptions: function() {
    this.ContentsSub = Meteor.subscribe('contents', this.findOptions());
    return Meteor.subscribe('allUserData');
  },
  Contents: function() {
    var locationArray= location.href.split('/');
    var UserId= locationArray[4];
    return contentsList.find({createdBy: UserId, anonymous: false}, this.findOptions());
  },
  data: function() {
    var hasMore = this.Contents().count() === this.contentsLimit();
    var nextPath = this.route.path({contentsLimit: this.contentsLimit() + this.increment});
    console.log("ready");
    return {
      Contents: this.Contents(),
      ready: this.ContentsSub.ready,
      nextPath: hasMore ? nextPath : null
    };
}
});

Router.map(function(){
  Router.route('profPageAuthorSubmit',{
    path: '/user/:createdBy/:contentsLimit?',
    controller: profileController
  });
});

为什么不显示加载按钮。我一次又一次地检查了它但仍然没有显示。同样的事情在其他模板中也有效。 基本上它是检查内容编号是否大于显示的数字,如果是,那么应该显示加载更多按钮。 感谢所有

1 个答案:

答案 0 :(得分:0)

据我所知,“ul”标签的每个孩子都必须是“li”标签。所以“a”不被认可。尝试将内容放在“li”标签内。