Skip to content

Instantly share code, notes, and snippets.

@ugisozols
Created October 16, 2013 10:39
Show Gist options
  • Save ugisozols/7005862 to your computer and use it in GitHub Desktop.
Save ugisozols/7005862 to your computer and use it in GitHub Desktop.
App.Entry = DS.Model.extend({
title: DS.attr("string"),
content: DS.attr("string")
});
<form {{action "createEntry" on="submit" }}>
{{input type="text" placeholder="Title ...." value=newTitle}}
<br>
{{textarea placeholder="Content" value=newContent}}
<br>
{{input type="submit" value="Create"}}
<hr>
</form>
App.NewController = Ember.ArrayController.extend({
actions: {
createEntry: function() {
var title = this.get("newTitle"),
content = this.get("newContent");
var entry = this.store.createRecord('entry', {
title: title,
content: content
});
entry.save();
this.set("newTitle", "");
this.set("newContent", "");
this.transitionToRoute("entries");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment