G
G
GaserV2017-02-24 15:45:46
Ember.js
GaserV, 2017-02-24 15:45:46

Why not clean the model?

Hey! Such a disaster. For example, I open the company/3/campaigns route. All campaigns that belong to a company with id = 3 are returned to me. For a company with id 3, for example, 3. 3 is displayed. OK. If you do not reload the page, return to the list of all companies, open another company, for example, with ID 4, which has only 1 campaign, then it displays 3 previous campaigns and + this one, i.e. 4. But if it reloads the page, then ok. 1 is displayed. What could be the problem?
PS companyCampaigns is always cleaned before putting anything into it, judging by the logic.
route:

model(params) {
      return this.get('store').query('campaign', {
        filter: {
          include: {
            relation: 'item',
            scope: {
              where: {
                companyId: params.company_id
              }
            }
          }
        }
      }).then(function(campaigns){
        var companyCampaigns = [];

        campaigns.forEach(function(campaign, index){

          if (campaign.get('item') !== undefined) {


           companyCampaigns.push(campaign)
          }

        })

        return companyCampaigns
      })
  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question