Created
December 29, 2011 05:14
-
-
Save kamal/1532069 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> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> | |
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.3.min.js"></script> | |
<script src="https://raw.github.com/gist/1531917/b8fd56c2033a1629d6497eb6784177cb4658d930/ember-data.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
window.App = Ember.Application.create(); | |
App.store = DS.Store.create({ | |
adapter: DS.Adapter.create() | |
}); | |
App.Venue = DS.Model.extend({name: DS.attr("string")}); | |
App.store.create(App.Venue, {name: "Foo", id: 1}); | |
App.venues = App.store.findAll(App.Venue); | |
App.VenueView = Ember.View.extend({ | |
click: function() { | |
this.get("content").set("name", Math.random().toString(36).substring(7)); | |
} | |
}); | |
var foo = App.venues.objectAt(0).set("name", "Bar"); | |
var baz = App.store.create(App.Venue, {name: "Baz", id: 2}); | |
baz.set("name", "Quux"); // this updates live just fine | |
}); | |
</script> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<ul> | |
{{#each App.venues}} | |
{{#view App.VenueView contentBinding="this"}} | |
{{#with content}} | |
<li>{{name}}</li> | |
{{/with}} | |
{{/view}} | |
{{/each}} | |
</ul> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment