Skip to content

Instantly share code, notes, and snippets.

@sebdah
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebdah/17e8fe5534be2d68eb53 to your computer and use it in GitHub Desktop.
Save sebdah/17e8fe5534be2d68eb53 to your computer and use it in GitHub Desktop.
Accessing parent data in MeteorJS
<template name="garage">
<h1>Garage: </h1>
Cars in the garage:<br/>
<ul>
{{#each cars}}
<li>{{registrationNumber}} {{owner}} - <button class="removeCar"></li>
{{/each}}
</ul>
</template>
{
_id: "1233",
name: "My garage"
cars: [
{
_id: "12341"
registrationNumber: "ABD 231",
owner: "Sebastian Dahlgren"
}
]
}
Template.garage.events({
'click button#removeCar': function (event, template) {
Garage.update(
{ _id: template.data._id },
{
$pull: {
cars: {
_id: this._id
}
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment