Javascript 余烬{{each}}帮助程序未显示完整列表
我的模板:Javascript 余烬{{each}}帮助程序未显示完整列表,javascript,ember.js,Javascript,Ember.js,我的模板: {{#each lesson_types}} {{name}}: ${{price}} {{/each}} {{#view App.EnterFormView action="pushType"}} {{input value=currentName placeholder="Lesson Name"}} {{input value=currentPrice placeholder="Lesson Price"}} {{/view}} <button {{act
{{#each lesson_types}}
{{name}}: ${{price}}
{{/each}}
{{#view App.EnterFormView action="pushType"}}
{{input value=currentName placeholder="Lesson Name"}} {{input value=currentPrice placeholder="Lesson Price"}}
{{/view}}
<button {{action "saveTypes"}}>Save</button>
而EnterFormView
只要在具有焦点时按下enter键,就可以在其父控制器上简单地触发它的方法
一切都很好,直到我以那种形式进入。如果我在这些输入中输入“Full”和“30”,然后输入“Half”和“15”,则每个输入中只会显示“Full”和“30”,即使pushType
的控制台输出显示:
undefined
[Class, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function, getEach: function…]
[Class, _super: undefined, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function…]
[Class, Class, _super: undefined, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function…]
因此您可以看到数组正在正确增长,{{{each}
只是没有显示所有的条目
值得指出的是,课程类型
是模型的一个属性
更新
这是一个扩展输出的粘贴箱
奇怪的是,第二个物体和第一个不同。发生了什么事?您应该使用pushObject而不是push Push不会通知ember阵列已更改
undefined
[Class, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function, getEach: function…]
[Class, _super: undefined, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function…]
[Class, Class, _super: undefined, nextObject: function, firstObject: undefined, lastObject: undefined, contains: function…]