mercredi 28 décembre 2016

Ember array option with ember power select

My model has 2 attributes (baseCurrency and otherCurrencies) whose values are selected in a form by 2 ember power selects dropdown menu whose options depend on 2 computed properties (baseCurrencyOptions and otherCurrencyOptions)

controller

  ...
  otherCurrencyOptions: Ember.computed('model.baseCurrency', function() {
    console.log(`allCurrencies changed to: ${this.get('allCurrencies')}`);
    return Ember.A(this.get('allCurrencies')).removeObject(this.get('model.baseCurrency'));
  }),
  baseCurrencyOptions: Ember.computed('model.otherCurrencies', function() {
    console.log(`allCurrencies changed to: ${this.get('allCurrencies')}`);
    return Ember.A(this.get('allCurrencies')).removeObjects(this.get('model.otherCurrencies'));
  }),
  actions: {
    addOtherCurrency(currency) {
      this.get('model.otherCurrencies').pushObject(currency);
    },
    selectCurrency(currency) {
      this.set('model.baseCurrency',currency);
    },
  ...

allCurrencies property contains a list of all currencies and it is not supposed to change over time.

template


  


  


Problem is that every time I select a currency in one or the other of both dropdown menus allCurrencies property gets updated loosing in an irreversibile manner every selected currency. Moreover I got the following warning:

DEPRECATION: You modified concatenatedTriggerClasses twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 3.0 [deprecation id: ember-views.render-double-modify]




Aucun commentaire:

Enregistrer un commentaire