Puedo incluir una matriz en un objeto Ember y mostrar los contenidos usando manubrios. Sin embargo, solo puedo reemplazar los contenidos de la matriz usando set(). ¿Cómo puedo modificar los contenidos de la matriz usando push/pop/etc. y todavía tienen la actualización de enlaces UI?¿Cómo hacer push/pop arrays en Ember.js?
// JS
App.obj = Ember.Object.create({
"things": ["1", "2"],
});
App.obj.set("things", ["1", "2", "3"]); // Works
App.obj.things.push("3"); // Doesn't Work
// HTML + Handlebars
{{#with App.obj}}
<ul>
{{#each things}}
<li>{{this}}</li>
{{/each}}
</ul>
{{/with}}
Perfecto. ¡Gracias! –
Referencia útil para pushObject y sus amigos (popObject, removeAt, etc): http://ember-docs.herokuapp.com/symbols/Ember.MutableArray.html –
Aquí también es útil la respuesta por la cual necesita usar esos métodos: http : //stackoverflow.com/questions/14582759/ember-containerview-not-updating-in-response-to-childviews-push – zigomir