I may be using the wrong words to describe my issue so here is the (simplified) code I'm working with.
I'm happy to learn a better way to do this but what I'm currently trying to do is pass {{assigneeId}}
to the template helper function called agentIs
. The problem is that I can't find the correct way to pass the value.
<template name="ticket_list">
{{#each tickets}}
{{> ticket}}
{{/each}}
</template>
<template name="ticket">
<h3>{{title}}</h3>
<p>{{assigneeId}}</p>
{{> ticket_footer}}
</template>
<template name="ticket_footer">
{{> agent_list}}
</template>
<template name="agent_list">
<!-- {{assigneeId}} exists here as expected -->
assigneeId: {{assigneeId}}
<label for="agent">Agent</label>
<select id="agent" name="agent">
{{#each agents}}
<!-- value passed: "{{assigneeId}}" -->
<option value="{{_id}}" {{#if agentIs "{{assigneeId}}"}}selected{{/if}}>
{{profile.name}}
</option>
<!-- value passed: undefined -->
<option value="{{_id}}" {{#if agentIs assigneeId}}selected{{/if}}>
{{profile.name}}
</option>
<!-- value passed: JSON.parse error -->
<option value="{{_id}}" {{#if agentIs {{assigneeId}}}}selected{{/if}}>
{{profile.name}}
</option>
{{/each}}
</select>
</template>
Template.agent_list.agents = function() {
return Meteor.users.find({"profile.is_agent": true}, {sort: {profile: 1}});
}
Template.agent_list.agentIs = function(assigneeId) {
return this._id === assigneeId;
};