Emberjs - 模型不会根据路线中的动态段进行刷新

时间:2014-12-01 08:00:24

标签: ember.js

在我的应用中,我有这种路线结构

Profile.Router.map(function() {
 this.resource('index', { path: '/:user' });
 this.resource('followers', { path: '/:user/followers' });
 this.resource('following', { path: '/:user/following' });
});

/:user/followers显示了':user'的关注者列表。 现在,当我从说 - /ross/followers转到/jack/followers时,也会为杰克的追随者路线显示相同的罗斯粉丝列表。这似乎是因为路由是ember中的单例,但我想知道的是如何在ember中处理这样一个基本用例。我希望保留每个/:user / following的模型,但希望每个不同的“用户”都能更改模型。

更新: 我使用link-to在/ross/followers/jack/followers之间进行转换。这是我的路线和控制器:

Profile.ProfileFollowersRoute = Ember.Route.extend({
  model: function(params) {
  },
  setupController: function(controller, model) {
    controller.set('cur_user', this.modelFor('profile').user);
    this._super(controller, model);
  },
  events: {
    fetchPage: function(page, perPage) {
      var that = this;
      Ember.$.getJSON('/'+this.modelFor('profile').user+'/followers/'+page+'?new=1').then(function(items){
        that.get('controller').send('gotMore',items, page);
      });
    }
  }
});

Profile.ProfileFollowersController = Ember.ArrayController.extend(InfiniteScroll.ControllerMixin,{
  perPage: 8,
  page: 0,
});

无限滚动插件启动数据提取。

0 个答案:

没有答案
相关问题