Emberjs - TextInput and Checkbox
by amindunited
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0.beta6/handlebars.min.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="https://github.com/downloads/pangratz/ember.js/ember-latest.js"></script>
<script type="text/x-handlebars" data-template-name="application">
{{view Em.TextField valueBinding="App.inputsController.firstName"}}
{{view Em.Checkbox checkedBinding="App.inputs.checkers"}}
</script>
CSS
body {
background-image: url(http://handlebarsjs.com/images/noise.png);
background-image: url("http://handlebarsjs.com/images/noise.png");
}
a {
cursor: pointer;
}
.foo {
color:red;
}
JavaScript
$(function(){
//Bind Application name to window
window.App = Em.Application.create({
autoInit: false
})
//Create Application controller, view and router
App.ApplicationController = Em.Controller.extend();
App.ApplicationView = Em.View.extend({});
App.router = Em.Router.create({
enableLogging:true,
location: 'none',
root:Em.Route.extend({
index:Em.Route.extend({
route:'/',
connectOutlets:function(router, context){
//router.get('applicationController').connectOutlet('lists', 'lists');
},
})
})
});
App.inputs = Em.Object.create({
checkers:false
});
App.inputsView = Em.View.create();
App.inputsController = Em.Controller.create({
firstName: null,
checkersBinding:'App.inputs.checkers',
firstNameListener: function(){
console.log("I saw the first name change");
console.log("and check box = ", this.get('checkers'));
}.observes('this.firstName')
})
//Start the app
App.initialize(App.router);
});