I want to execute a nested loop in meteor


#1
{{#each boards}}
{{board_name}}
{{#each bEvents}}
{{event_name}} <br/><br/>
{{/each}}													
{{/each}}

I want to execute a nested loop in meteor. First loop is executed but second loop did not executed.

#2

does “boards” consist of/returns array of objects which have bEvents property ?


#3

Show us your template helpers, please!


#4

Do you want to do this all in one template? It seems like something which belongs in multiple templates like:

  • boards
  • board
  • eventsList
  • event

See also this topic of today which might relate to your issue:


#5

the issue you linked is just cause you dont know exact timing when are helper based elements rendered and you are using child templates cause of theirs onRendered which is run after they finished rendering.


#6

Template.room.helpers
boards: ->
return ChatBoard.find({ rid: this._id })

bEvents: ->
	return ChatEvent.find({ room_id: this._id })

This is my template helper.

I am new in meteor. That’s why I am struggling. Plz help me out.


#7

Shock Please write some example.


#8

you need to split it to separate template

or call {{#each bEvents this }}
and in helper

bEvents: (element) ->
  ChatEvent.find({room_id: element._id})

or I would expect it to be these 2 options

PS: and use @ instead of this. in coffee :smiley:


#9

It would probably be useful to see an example of the payload from ChatEvent.find({ room_id: this._id })

here’s an example of a nested #each


#10

Thanks dude. Let me try into my project.