I want to execute a nested loop in meteor

{{#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.

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

1 Like

Show us your template helpers, please!

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:

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.

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.

Shock Please write some example.

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:

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

Thanks dude. Let me try into my project.