Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

How can I bind data returned from the model hook to the template?

$
0
0

@andrew1 wrote:

I have a model hook in my route that returns an Ember.RSVP.hash with one of the elements being an array:

AlertsIndexRoute = Ember.Route.extend(
  AuthenticatedRouteMixin,
  {
    tasks: Ember.computed -> @store.peekAll('task')
    alerts: Ember.computed.filterBy('tasks', 'category', 'ALERT')

    filteredAlerts: Ember.computed 'alerts.@each.status', ->
      @get('alerts').rejectBy('status', 'DRAFT').rejectBy('status', 'DELETED')

    model: ->
      @fetchContent(@store.peekAll('organization'))
      return Ember.RSVP.hash
        columns: @get('columns')
        content: @get('filteredAlerts')

    fetchContent: (organizations) ->
      @store.query('task', {
        category: 'ALERT'
        organization_id: organizations.get('firstObject.id')
      }).then (results) ->
        return results.rejectBy('status', 'DRAFT').rejectBy('status', 'DELETED')
  }
)

The problem is that when AlertsIndexRoute#filteredAlerts is updated, those changes are not propagating through to the controller:

Can anyone point out where I'm going wrong? I thought returning the data from the model hook was the Ember Way (tm) but I'm beginning to think I should just lookup the data directly in the controller.

Any help would be greatly appreciated.

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles