lundi 24 août 2015

ember select - where to fetch collection of options so that they aren't considered part of the model?

I have a model Foo which has a has a barId which a belongsTo relationshiop to a model Bar. I want to have a menu of Bars on my "new" Foo template.

I've already created a select component which displays things properly.

Where is the appropriate place for me to do a JSON fetch of the Bar collection? I'm assuming it should be stored in the controller as it decorates the model and makes extra context available to the template.

Doing an RSVP.hash() in the router's model() doesn't seem appropriate to me, as it would consider the Bar collection part part of the Foo model. Should I be using the router's afterModel()/setupController(), the controller's init() or something else?

Sorry I don't have a jsFiddle or anything, I don't know how to set one up now that my code requires babel.

Any help would be appreciated




Aucun commentaire:

Enregistrer un commentaire