Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Last active December 29, 2015 23:28
Show Gist options
  • Save dadamssg/7742592 to your computer and use it in GitHub Desktop.
Save dadamssg/7742592 to your computer and use it in GitHub Desktop.
Select2 is passing an object literal into the handleCompanySelect method on the PeopleNewController.
App.PeopleNewController = Ember.ObjectController.extend({
companySelection: null,
actions: {
doneEditing: function () {
var person = this.get('model');
person.save();
},
handleCompanySelect: function(company) {
var companyId = Ember.get(company, 'id');
this.store.find('company', companyId).then(function(company){
var person = this.get('model');
person.set('company', company);
company.get('people').pushObject(person);
});
}
}
});
App.Company = App.Taskable.extend({
name: DS.attr('string'),
people: DS.hasMany('person')
});
App.Person = App.Taskable.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
city: DS.attr('string'),
state: DS.attr('string'),
email: DS.attr('string'),
company: DS.belongsTo('company')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment