Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.0.2.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" data-template-name="application">
{{view Ember.Select content=options value=computed}}
<p><code>content</code> was initially <code>{{unbound contentInspect}}</code> and is now <code>{{contentInspect}}</code></p>
<p><code>parent</code> was initially <code>{{unbound parentInspect}}</code> and is now <code>{{parentInspect}}</code></p>
</script>
</body>
</html>
App = Ember.Application.create({});
override = function(key, value) {
if (arguments.length > 1) {
this.set("content", value);
}
else {
return this.get("content") || this.get("parent");
}
};
inspect = function(property) {
return function() {
return JSON.stringify(this.get(property));
}.property(property);
};
App.ApplicationController = Ember.Controller.extend({
options: ["foo", "bar", "baz"],
content: null,
contentInspect: inspect("content"),
parent: "bar",
parentInspect: inspect("parent"),
computed: override.property("content", "parent")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.