Skip to content

Instantly share code, notes, and snippets.

@sarahkadar
Created March 13, 2012 12:12
Show Gist options
  • Save sarahkadar/2028431 to your computer and use it in GitHub Desktop.
Save sarahkadar/2028431 to your computer and use it in GitHub Desktop.
var App = Em.Application.create();
var Player = Em.Object.extend({
level: 1,
name: null,
});
App.jane = Player.create({ name: "Jane"});
App.view = Em.View.create({
templateName: 'player-view',
counterBinding: 'App.jane.level',
up: function() {
App.jane.set('level', App.jane.get('level') + 1);
},
down: function() {
App.jane.set('level', App.jane.get('level') == 1 ? 1 : App.jane.get('level') - 1);
}
});
App.view.append();
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Munchkin counter for iPad</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="css/style.css?v=2">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<script type="text/x-handlebars" data-template-name="player-view">
<a href="#" {{action "up" on="click"}}>UP</a>
<div>{{ counter }}<div>
<a href="#" {{action "down" on="click"}}>DOWN</a>
</script>
<div id="container"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.6.1.min.js"%3E%3C/script%3E'))</script>
<script src="js/libs/ember-0.9.5.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment