Last active
December 29, 2015 23:28
-
-
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.
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.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); | |
}); | |
} | |
} | |
}); |
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.Company = App.Taskable.extend({ | |
name: DS.attr('string'), | |
people: DS.hasMany('person') | |
}); |
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.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