Emberjs同时发出2个请求

时间:2016-07-06 17:13:39

标签: javascript ember.js ember-data ember-cli

我的router.js文件是这样的:

  this.route('cards', function() {
    this.route('all');
    this.route('card', {path: '/:card_id'}, function() {
      this.route('edit');
    });
    this.route('new');
  });

all.js,我:

  model() {
    return this.store.findAll('card');
  }

cards.js,我:

  beforeModel() {
    this.transitionTo('cards.all');
  },

  model() {
    return this.store.findAll('card');
  }

正如你所看到的,我正在提出2个请求,而IMO则没有必要。因此,如果我从cards.js移除了来电,则new.js无效。

当我从new.js创建新卡片后,在创建后,它应转到/cards/1并显示正确的数据。但是,当我从cards.js删除该行后,在创建卡后,它会转到/cards/1,但数据不会被保存。

链接到回购:https://github.com/ghoshnirmalya/hub-client

0 个答案:

没有答案