Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Buggy Meteor App
/* CSS declarations go here */
<head>
<title>DrinkTabThing</title>
</head>
<body>
{{renderPage}}
</body>
<template name="tab">
<h1>Menu</h1>
{{#each drinks_menu}}
{{> drink_from_menu}}
{{/each}}
<hr>
<h1>My Tab</h1>
{{#each ordered_drinks}}
{{> drink_from_tab}}
{{/each}}
</template>
<template name="drink_from_menu">
<div>{{name}}: ${{price}}<input type="button" value="buy one" class="buy_drink"/></div>
</template>
<template name="drink_from_tab">
<div>{{name}}: ${{price}}</div>
</template>
Tabs = new Meteor.Collection('tabs');
Drinks = new Meteor.Collection('drinks');
if (Meteor.isClient) {
Meteor.Router.add({
'/': 'home',
'/tabs/:id': function (id) {
Session.set('tabId', id);
return 'tab';
}
});
Template.tab.drinks_menu = function(){
return Drinks.find({});
};
Template.tab.ordered_drinks = function () {
return Tabs.findOne(Session.get('tabId')).ordered_drinks;
};
Template.drink_from_menu.events({
'click .buy_drink': function () {
Tabs.update({_id:Session.get('tabId')}, {$push: {ordered_drinks: this}});
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
Meteor.Router.add({
'/tabs/:id.xml': function(id) {
return Tabs.findOne(id).owner;
}
});
if (Drinks.find().count() === 0) {
Drinks.insert({name: "Screwdriver", price: "5.00"});
Drinks.insert({name: "Rum and Coke", price: "5.50"});
Drinks.insert({name: "Kilkenny's", price: "8.00"});
}
});
}
@alanning

I put together a fixed version of this here: https://github.com/alanning/meteor-buggy-fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.