Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/tags/v1.7.0/ember.js"></script>
<script src="http://builds.emberjs.com/canary/ember-data.js"></script>
</head>
<body>
<script type="text/x-handlebars" data-template-name="application">
<h1>ember-latest jsbin</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<h2>Apple Ratings</h2>
<ul>
{{#each persistedModels}}
<li>{{name}}: {{rating}}</li>
{{/each}}
</ul>
{{render "new-apple-form" newApple}}
</script>
<script type="text/x-handlebars" data-template-name="new-apple-form">
{{input placeholder="Name..." value=name}}
{{input placeholder="Rating..." value=rating}}
<button {{action "saveApple" item}}>Save</button>
</script>
<script id="jsbin-javascript">
App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter;
App.Apple = DS.Model.extend({
name: DS.attr('string'),
rating: DS.attr('number')
});
App.Apple.FIXTURES = [
{id: 1, name: 'Granny Smith', rating: 7},
{id: 2, name: 'Fuji', rating: 10},
{id: 3, name: 'Gala', rating: 6}
];
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('apple');
}
});
App.NewAppleRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('apple');
}
});
App.IndexController = Ember.Controller.extend({
newApple: function() {
return this.store.createRecord('apple');
},
persistedModels: Ember.computed.filterBy('model', 'isNew', false),
actions: {
saveApple: function(model) {
model.save();
}
}
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter;
App.Apple = DS.Model.extend({
name: DS.attr('string'),
rating: DS.attr('number')
});
App.Apple.FIXTURES = [
{id: 1, name: 'Granny Smith', rating: 7},
{id: 2, name: 'Fuji', rating: 10},
{id: 3, name: 'Gala', rating: 6}
];
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('apple');
}
});
App.NewAppleRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('apple');
}
});
App.IndexController = Ember.Controller.extend({
newApple: function() {
return this.store.createRecord('apple');
},
persistedModels: Ember.computed.filterBy('model', 'isNew', false),
actions: {
saveApple: function(model) {
model.save();
}
}
});</script></body>
</html>
App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter;
App.Apple = DS.Model.extend({
name: DS.attr('string'),
rating: DS.attr('number')
});
App.Apple.FIXTURES = [
{id: 1, name: 'Granny Smith', rating: 7},
{id: 2, name: 'Fuji', rating: 10},
{id: 3, name: 'Gala', rating: 6}
];
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find('apple');
}
});
App.NewAppleRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('apple');
}
});
App.IndexController = Ember.Controller.extend({
newApple: function() {
return this.store.createRecord('apple');
},
persistedModels: Ember.computed.filterBy('model', 'isNew', false),
actions: {
saveApple: function(model) {
model.save();
}
}
});
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.