Created
October 28, 2012 05:21
-
-
Save drorm/3967712 to your computer and use it in GitHub Desktop.
Handlebars race condition
This file contains hidden or 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
<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> |
This file contains hidden or 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
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