[SOLVED] Nested document not reactive


I subscribe to a collection (template level) and store it into an instance variable of the template.

Accessing the data via a simple helper works fine, but when it comes to the nested documents (each ticket has x tasks) the template does not re-render when a new nested document is added.

Here the helper function for the sub-documents:

How can I make the nested-document list reactive again?

Nested reactive publish

First `You could use Tickets.findOne(FlowRouter.getParam('_id)) and it is faster on the client then {_id: FlowRouter.getParam('_id)}

Second this.ticket = ... inside onCreated doesnt trigger your tasks helper to recalculation. I guess the best solution for you should be:

onCreated: ->
  this.ticketId = FlowRouter.getParam('_id')

tasks: ->
  ticketId = Template.instance().ticketId
  ticket = Tickets.findOne(ticketId)
  tasks = <fetch an filter data from ticket>


Good solution, thank you! Here the adjusted (and working code):


Note that you should be safe with the line
self.projectID = Tickets.findOne(self.ticketID).project

When you call subscribe it is a some time for new records are coming from server. On that time Tickets.findOne(self.ticketID) returns undefined. It is safer to do it like

    self.subHandler = self.subscribe(...)
    if self.subHandler.ready()
      self.projectID = Tickets.findOne(self.ticketID).project

  if self.subHandler