I have an ApplicationController in which when "Ember.select" change value I want to refresh some models.
App.ApplicationController = Ember.ObjectController.extend({
needs: ['abstractAuth', 'widgets', 'modalWindows', 'chatCompose', 'chatModal', 'about', 'contacts'],
selectedDomainAlias: {},
selectedDefaultValue: { Id: 2 },
onSelectedDomainAliasChange: function () {
var self = this;
var getSelectedDomain = this.get("selectedDomainAlias.domainName");
$.get('/SetCookies/Cookies?domains=' + getSelectedDomain, false)
.then(function() {
self.send("domainChanged");
self.get('model').reload();
var contacts = App.controllerFor('contacts').store.find('contact');
self.get('controllers.contacts').set('model', contacts);
});
}.observes('selectedDomainAlias.length')});
"self.send("domainChanged");" and "self.get('model').reload();" work correctly. I also have model "Contact", which I should refresh. "App.controllerFor('contacts').store.find('contact');" - receives a model from backend. But I couldn't refresh correctly "Contact" model. If at first I have two contacts in model. And when I try replace this two contacts per one contact, this contact added as third contact, but I want to get only one contact. How can I refresh "Contact" model correctly?
Aucun commentaire:
Enregistrer un commentaire