Skip to content

Instantly share code, notes, and snippets.

@drorm
Created October 28, 2012 05:21
Show Gist options
  • Save drorm/3967712 to your computer and use it in GitHub Desktop.
Save drorm/3967712 to your computer and use it in GitHub Desktop.
Handlebars race condition
<title>race</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<h1>Hello World!</h1>
<br/>
<h1>
{{#if configured}}
User configured
{{else}}
User not configured
{{/if}}
</h1>
{{greeting}}
<input type="button" value="Click" />
</template>
f (Meteor.isClient) {
var userConfigured = false;
Template.hello.greeting = function () {
return "Welcome to race.";
};
Template.hello.configured = function () {
var localConfigured = (Session.get('userConfigured'));
return (localConfigured);
};
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
userConfigured = !userConfigured;
console.log("userConfigured:" + userConfigured);
Session.set("userConfigured", userConfigured);
alert('toggle');
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment