1

I have a master detail view like show in the below mockup:

enter image description here

The outlet on the left, the master view, contains the Index Route. The outlet on the right contains the show route.

The "widget" is the core model held in the Object Controller's content property. There are two other models loaded as well, which are fetched in the route's model hook via Ember.RSVP.hash and then assigned to controller properties in setupController.

So this is all working great, however I'm running into an issue when I select a new widget on the left. The URL updates with the new ID dynamic segment, but the model hook is not evaluated. It goes straight to setup controller, and the model value is now undefined. It does not enter any intermediary route.

App.WidgetsShowRoute = Ember.Route.extend

  # Query Params for managing the paginated tables
  queryParams:
    someInfoPageSize:
      refreshModel: true
    someInfoPage:
      refreshModel: true
    otherPageSize:
      refreshModel: true
    otherPage:
      refreshModel: true

  model: (params) ->
    console.log "Give me some models!"
    @modelFor('widgets') # Get make sure the master route has loaded
    store = @get('store')
    store.find("widget", params.widget_id).then (result) ->
      promises = {
        widget: result
        info: store.findQuery("some_info", {
          group_id: result.get('widgetId')
          per_page: params.someInfoPageSize or 10
        })
        other_info: store.findQuery("other_info", {
          name: result.get('name')
          per_page: params.otherPageSize or 10
          page: params.otherPage or 1
        })
      }
      Ember.RSVP.hash(promises)

  setupController: (controller, models) ->
    console.log "Setting Up Controller"
    infoMeta = @store.metadataFor("some_info")
    otherMeta = @store.metadataFor("other_info")
    console.log "content should be #{models.widget.get('name')}"
    controller.setProperties
      content: models.widget
      someInfo: models.some_info
      groupAccount: models.other_info
      # ... a bunch of different metadata assignments from the service

  resetController: (controller, isExiting, transition) ->
    # tried resetting all the properties here to no avail, didn't affect model hook being called

  actions:
    willTransition: (transition) ->
      # hooking into this to set loading state on tables
      @controller.setProperties
        infoLoading: true
        otherLoading: true

      # tried calling to super in case that affected the model hook being called.
      @_super(transition)
DVG
  • 17,392
  • 7
  • 61
  • 88

0 Answers0