Created
September 3, 2013 21:24
-
-
Save anonymous/6429814 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script> | |
<script src="http://builds.emberjs.com/ember-latest.js"></script> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
Count is {{count}} | |
</script> | |
</body> | |
</html> | |
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
App = Ember.Application.create(); | |
App.ApplicationController = Ember.Controller.extend({ | |
count: 0, | |
incrementCount: function() { | |
this.incrementProperty('count'); | |
// Ember.run.later is Ember setTimeout wrapper: | |
// In 1000ms, call this.incrementCount(), | |
// safely nested in a run loop. | |
// Note that Ember is badass enough that | |
// strictly speaking you don't need all callbacks | |
// to take place in a run loop, but it's a good | |
// habit to get into as it can avoid "autoruns" | |
// which might lead to some non-determinism | |
// and performance issues in complex apps. | |
// Plus being able to pass in the `this` context | |
// is nice. | |
Ember.run.later(this, 'incrementCount', 1000); | |
}.on('init') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment