Created
January 26, 2012 22:40
-
-
Save sbuller/1685575 to your computer and use it in GitHub Desktop.
Ember Test
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> | |
<head> | |
<title>Ember Test</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script type="text/javascript" src="https://github.com/downloads/emberjs/ember.js/ember-0.9.4.min.js"></script> | |
<script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script> | |
</head> | |
<body> | |
<h1>Todos</h1> | |
<script type="text/x-handlebars"> | |
{{view Todos.CreateTodoView id="new-todo" | |
placeholder="What needs to be done?"}} | |
</script> | |
<script type="text/coffeescript"> | |
# src="app.coffee" | |
Todos = Em.Application.create() | |
Todos.Todo = Em.Object.extend { | |
title: null, | |
isDone: false | |
} | |
Todos.todosController = Em.ArrayProxy.create { | |
content: [], | |
createTodo: (title) -> | |
todo = Todos.Todo.create {title:title} | |
this.pushObject todo | |
} | |
Todos.CreateTodoView = Em.TextField.extend { | |
insertNewline: () -> | |
value = this.get 'value' | |
if value | |
Todos.todosController.createTodo value | |
this.set 'value', '' | |
} | |
window.Todos = Todos | |
</script> | |
<script type="text/javascript"> | |
//* src="app.js" | |
(function() { | |
var Todos; | |
Todos = Em.Application.create(); | |
Todos.Todo = Em.Object.extend({ | |
title: null, | |
isDone: false | |
}); | |
Todos.todosController = Em.ArrayProxy.create({ | |
content: [], | |
createTodo: function(title) { | |
var todo; | |
todo = Todos.Todo.create({ | |
title: title | |
}); | |
return this.pushObject(todo); | |
} | |
}); | |
Todos.CreateTodoView = Em.TextField.extend({ | |
insertNewline: function() { | |
var value; | |
value = this.get('value'); | |
if (value) { | |
Todos.todosController.createTodo(value); | |
return this.set('value', ''); | |
} | |
} | |
}); | |
window.Todos = Todos; | |
}).call(this); | |
//*/ | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment