Created
October 19, 2014 16:57
-
-
Save fishermand46/713650c20b29a73d76e1 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/pudaz
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
<!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> |
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
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