mercredi 14 décembre 2016

Ember 2.10, updating component on array pushObject

I have two components that should both reflect the same data (testing d3 in ember)

One of the components adds a node to my state and also lists those nodes. The state is an array and I believe I am correctly calling pushObject in order to notify everything that there are updates.

The other is going to be a d3 thing so nothing is being rendered by the hbs file and I need to be notified when the array is modified so I can call the appropriate d3 functions and rerender my force graph.

I setup a minimal twiddle here: http://ift.tt/2hvAXpu

Basically, when you press add node: it adds a node to the list so I know some event is being fired however, my draw function in the "twiglet-graph" component is not being called.

To see this in action, goto the fiddle and press "Add". When you add another node, it will correctly list two nodes on the top part but it never changes the length in the bottom component to 2. I setup a click event that will alert you of the length of that component's this.nodes and clicking after adding shows a length of 2. How do I hook into the update so I can redraw my force graph?

Thanks.




Aucun commentaire:

Enregistrer un commentaire