Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Created October 25, 2013 16:10
Show Gist options
  • Save dadamssg/7157220 to your computer and use it in GitHub Desktop.
Save dadamssg/7157220 to your computer and use it in GitHub Desktop.
window.App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter.extend();
App.PersonController = Ember.ObjectController.extend({
isEditing: false,
actions: {
edit: function() {
this.set('isEditing', true);
},
doneEditing: function() {
this.set('isEditing', false);
}
}
});
App.PeopleNewController = Ember.ObjectController.extend({
actions: {
doneEditing: function () {
var name = this.get('name');
if (!name.trim()) { return; }
var city = this.get('city');
if (!city.trim()) { return; }
// Create the new person model
var person = this.store.createRecord('person', {
name: name,
city: city
});
// Clear the fields
this.set('name', '');
this.set('city', '');
// Save the new model
person.save();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment