Preface: I am an EmberJS newb
I am working on a project that displays a form for a user to edit an Event. There are multiple associations in this model, one of them is eventImages.
eventImages: DS.hasMany("event-image", { async: true })
Here is my EventImage model
`import DS from 'ember-data'`
EventImage = DS.Model.extend
event: DS.belongsTo('event', { async: true })
### NATURAL ATTRIBUTES ###
imageUrl: DS.attr("string")
fileName: DS.attr("string")
fileSize: DS.attr("string")
primary: DS.attr("boolean")
featured: DS.attr("boolean")
`export default EventImage`
On the Event form, I have a place where a user can upload multiple images to be shown on the front-end for the event they are editing/creating. The problem is that I can't seem to put the pieces together on how the event model fetches the associated data from the API.
The backend (Rails) routes, are /api/events and /api/events/:event_id/event_images, but when the edit form loads, I don't see an ajax call to fetch the event images.
Here is my edit.coffee file in routes:
`import Ember from 'ember'`
`import DirtyConfirmRouteMixin from 'my-app/mixins/dirty-confirm-route'`
EventEditRoute = Ember.Route.extend DirtyConfirmRouteMixin,
setupController: (controller, model) ->
@_super(controller, model)
@controllerFor("event-type-selector").set("promise", @store.find("event-type", forSelector: true))
@controllerFor("venue-selector").set("promise", @store.find("venue", forSelector: true))
`export default EventEditRoute`
Any help at all on how to fetch associated data and displaying those items in a handlebars template would be greatly appreciated. I am certainly willing to paste any more of the code that is needed. Thanks
Aucun commentaire:
Enregistrer un commentaire