My app generates a table using #each events
.
There are 4 event tickets per row (each row represents an event) and when you click on, for example, the first ticket, this is what's executed:
Template.displayEventsTable.events({
"click .buyTicket1": function () {
buyEventTicket(1, this._id);
}
This is the buyTicket
function:
function buyEventTicket (whatNumber, whatEvent) {
var buyer = Meteor.user();
console.log(whatNumber); // works
console.log(whatEvent); // works
console.log(whatEvent.eventTicketPrice); // currently shows up as "undefined"
};
}
The place I'm stuck with is trying to get the eventTicketPrice, which shows up as undefined. Despite reading through the Meteor and HandleBars docs, the light hasn't switched on yet as to what could be causing this.
It doesn't seem logical that the event ID wouldn't return the proper value for one of its own fields.
What have I missed?
EDIT 1
HTML Template
<template name="myEvents">
<h2>Events</h3>
<table>
<tr class="first-row">
<th>Ticket 1</th>
<th>Ticket 2</th>
<th>Ticket 3</th>
<th>Ticket 4</th>
</tr>
{{#each events}}
{{#if eventsTypeA 1}}
{{> displayEventsTable}}
{{/if}}
{{/each}}
</table>
</div>
</div>
</template>
Events Table Template
<template name="displayEventsTable">
<tr>
<td><button class="buyTicket1 button-blue">Buy #1</button></td>
<td><button class="buyTicket2 button-blue">Buy #2</button></td>
<td><button class="buyTicket3 button-blue">Buy #3</button></td>
<td><button class="buyTicket4 button-blue">Buy #4</button></td>
</tr>
</template>
EDIT 2
_id: "YQXvUoBGKvhPObzFw"
createdAt: Sat Jan 02 2016 22:47:35 GMT+0100 (CET)
eventStatus: "open"
eventTicketPrice: 30
eventTickets: Array[4]
__proto__: Object