Skip to content

Instantly share code, notes, and snippets.

@digilord
Forked from anonymous/client.html
Last active August 29, 2015 13:56
Show Gist options
  • Save digilord/9250236 to your computer and use it in GitHub Desktop.
Save digilord/9250236 to your computer and use it in GitHub Desktop.
<head>
<title>ffff</title>
</head>
<body>
<h1>ffff</h1>
{{> welcome }}
{{> persons }}
</body>
<template name="welcome">
<p>
Hello.
</p>
</template>
<template name="persons">
{{#each people}}
<div class="{{selectedPerson}}">
{{name}} <strong>@{{twitter}}:</strong> <!-- twitter & name are attributes on a people object-->
<button class="person-detail-alert">Give me more info</button>
</div>
{{/each}}
</template>
Template.persons.helpers({
people: function(){
var people = People.find({}).fetch(); // People is a Collection
return people
},
selectedPerson: function(){
if(this._id === Session.get("SelectedPerson")._id)
return "alert alert-info"
}
});
Template.persons.events({
"click .person-detail-alert": function(event, template){
var person = this;
alert("You clicked "+ person.name);
Session.set("SelectedPerson", person);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment