Created
June 27, 2013 21:49
-
-
Save tilleps/5880718 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
// | |
// HTML | |
// | |
<html> | |
<head></head> | |
<body class="loading"></body> | |
</html> | |
// | |
// Template (layout.hbr) | |
// | |
<div> | |
Layout #1 | |
<div>Hello {{person}}!</div> | |
<div> | |
<div>Count: <span class="count">{{count}}</span></div> | |
<button class="increment">increment</button> | |
<button class="decrement">decrement</button> | |
</div> | |
</div> | |
// | |
// app.js | |
// | |
var theCount = can.compute(0); | |
var App = can.Control({ | |
init: function(element, options) { | |
var self = this; | |
self.element.removeClass('loading'); | |
self.element.html('layout.hbr', { | |
person: "world", | |
count: can.compute(theCount) | |
}); | |
}, | |
'button.increment click': function() { | |
theCount(theCount()+1); | |
}, | |
'button.decrement click': function() { | |
theCount(theCount()-1); | |
}, | |
}); | |
new App('body', {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment