mercredi 16 septembre 2015

Template is not rerendering / auto-updating loop about changed controller variable

Given 2 array items when I add new input then I want to see 3 array items but still only see 2 array items.

This is my current code ...

Route

    model: (params) ->
      @controllerFor('pages').set 'myArray', []

Template

<ul>
  {{#each myArray as |item itemIndex|}}
    <li>{{item}}</li>
  {{/each}}
</ul>
<input id="my_input"/><button {{action 'addInput'}}/>

Controller

    addInput: ->
      array = @get('myArray')
      array.push $('#my_input').val()
      @set 'myArray', array

How can I get the template to rerender / auto-update the loop about changed controller variable "myArray"?

I'm using Ember 1.13.8.




Aucun commentaire:

Enregistrer un commentaire