SuperUberDuper
SuperUberDuper

Reputation: 9623

Ember array not updating template

Whats the likely cause of when you update an array in the controller and the update is not shown in the view (where as it works when the page loads initially).

My action that does the update:

  submit: function (foo) {
      let arr = this.get("baa");
      arr.push(foo);
      this.set("items", arr);
    }

template:

 {{view "select" content=items   class="form-control"}}

anything thats pushed is not reflected in the rendered select.

Upvotes: 1

Views: 766

Answers (1)

enspandi
enspandi

Reputation: 663

I suspect you aren't using Ember Arrays. Try .pushObject instead of .push.

arr = Em.A()
arr.pushObject()

http://emberjs.com/api/classes/Ember.MutableArray.html "It is important to use the methods in this class to modify arrays so that changes are observable. This allows the binding system in Ember to function correctly."

Upvotes: 2

Related Questions