jeudi 10 mars 2016

Model hook only runs by link-to

I have this booking model hook:

  model (params) {
    return this.store.query('booking', {
      'relationships.event.data.id': params.event_id
    });
  }

And he only run if i access from the link-to in my events page. If i try to access from the url, e.g: http://ift.tt/1nBnawb, this will cause:

ember.debug.js:30073 Error while processing route: bookings.edit Cannot read property '_internalModel' of undefined TypeError: Cannot read property '_internalModel' of undefined

Also, i already tested a lot (trying to find the error), and the booking model hook is not being called at all when i access from the url, i tested with a console.log.

This is my event model hook:

 model() {
    return this.store.findAll('event')
      .then(items => {
        items.forEach(item => {
          this.store.query('booking', {
           'relationships.event.data.id': item.id
         }).then(booking => item.set('bookings', booking));
        });
        return items;
      });
  }

Thanks!




Aucun commentaire:

Enregistrer un commentaire