3

I have a series of nested objects. Say like... stores and items.

I have perhaps 10 stores, each with the same 10 items, displayed on the screen at the same time.

<template name='store'>
  {{#each items}}
   {{> item}}
  {{/each}}
</template>


<template name='item'>
  {{name}} {{qty}}
</template>

The main problem I have is trying to determine {{qty}} using a helper function. This is because the item inherently does not have a 'quantity', but rather it depends on which "store" it is related to. So I'd need to find the quantity based on the "store" + "item".

What's the "meteor way" of searching for this? Is it to store a bunch of data -* attributes in the DOM and search out my mongdb _id items via Jquery? I don't think mustache allows you to figure out where you came from and access a "parent scope's variables". And it's not like backbone where I can just add that link from the parent-store view to the child-item views.

I don't feel comfortable using session variables because I'm worried that that may cause race conditions (such as Session.get('current_store_id')).

Thanks!

pctj101
  • 141
  • 2
  • 5

1 Answers1

2

Handlebars supports ../ in paths, which might help:

http://handlebarsjs.com/#paths

dgreensp
  • 449
  • 2
  • 4
  • Thanks for the tip on the github issue, I created the following function (coffeescript) and it solved the event-handling issue: parentContext = (node) -> context = Meteor.ui._LiveRange.findRange Meteor.ui._tag, node; return null unless (parent = do context.findParent)?; return parent.event_data; – Vic Goldfeld Jun 17 '12 at 20:00