1

我有一个模板在 10 次中有 9 次被正确渲染,但有时不是,它只是没有显示。日志中似乎没有任何错误消息,我应该如何调试呢?会是什么呢?

主模板(application.hbs)构建为:

<div class="row-fluid">
  <div class="span12 page_top_header base_color_background"></div>
</div>
<div class="container-fluid">
  <div class="row-fluid header_container">
    <!-- Logo -->

    <!-- Menu -->

  </div>
</div>
<!-- Line Divider -->
<div class="row-fluid ">
  <div class="span12 page_top_header line-divider"></div>
</div>

</div>
{{outlet}}
{{render footer}}

页脚本身主要是文字,在控制器里有几个道具,没什么花哨的。我有以下日志记录:

App = Ember.Application.create({
  LOG_TRANSITIONS: true,
  LOG_VIEW_LOOKUPS: true,
  LOG_ACTIVE_GENERATION: true,
  LOG_BINDINGS: true,

  currentUser: null
});

欢迎任何建议。

编辑

应用控制器和路由器:

App.ApplicationController = Ember.Controller.extend({
  needs: ['currentUser'],

  init: function() {
    'use strict';

    this._super();

    $.pnotify.defaults.history = false;
    $.pnotify.defaults.delay = 5000;
  },

  logout: function() {
    'use strict';

    var self = this;
    $.ajax({
      url: '/users/sign_out.json',
      type: 'DELETE',
      success: function(){
        $.pnotify({type: 'success', title: 'Afmelden', text: 'U ben succesvol afgemeld.'});

        self.set('controllers.currentUser.content', null);
        self.transitionToRoute('index');
        window.location.href = window.location.href;
        window.location.reload();
      }
    });
  }
});

App.ApplicationRoute = Ember.Route.extend({
  beforeModel: function() {
    var attributes = $('meta[name="current-user"]').attr('content');
    if (attributes) {
      var user = App.User.create().setProperties(JSON.parse(attributes));
      this.controllerFor('currentUser').set('content', user);
    }
  }
});
4

0 回答 0