Skip to content

Instantly share code, notes, and snippets.

@jkintscher
Created December 3, 2013 04:02
Show Gist options
  • Save jkintscher/7763693 to your computer and use it in GitHub Desktop.
Save jkintscher/7763693 to your computer and use it in GitHub Desktop.
Ember-Model FixtureAdapter
<!DOCTYPE html>
<html>
<head>
<title>Fixture Adapter</title>
<script src="http://code.jquery.com/jquery-2.0.3.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.1.2.js"></script>
<script src="http://builds.emberjs.com/tags/v1.2.0/ember.js"></script>
<script src="http://builds.erikbryn.com/ember-model/ember-model-c45f01c08f2a951c2c2dee07122ea5420bf4e17a.js"></script>
</head>
<body>
<script>
$(function(){
// ++ App
window.App = Ember.Application.extend({
rootElement: 'body'
});
// ++ Models
App.Project = Ember.Model.extend({
id: Ember.attr(),
name: Ember.attr()
});
App.Project.adapter = Ember.FixtureAdapter.create();
App.Project.FIXTURES = [];
App.create();
console.debug("clientIdCounter before model:", App.Project._clientIdCounter);
var p = App.Project.create({
name: 'Tomhuda'
});
console.debug("ID before save:", p.get('id'));
console.debug("clientIdCounter before save:", App.Project._clientIdCounter);
p.save().then(function() {
console.debug("ID after save:", p.get('id'));
console.debug("clientIdCounter after save:", App.Project._clientIdCounter);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment