-
-
Save digilord/9250236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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