템플릿의 각 도우미에서 업데이트하지, 난 엠버 새로운 오전과 나는 기본적으로 내가 포함 된 중첩 된 데이터 엠버 모델의 hasMany의를 사용하고, 여기에 무슨 일이 일어나고 있는지 고칠 수 (각 송장에 대한 항목을 배열에), 나는 jsbin와 jsfiddle에 코드를 넣어 시도하지만 난 여기에 내 보관함에 보관을 넣어 도움이 시간이 사람들 그래서, 거기 작동하지 않습니다 Ember-Model hasMany not updating in template's {{#each}}엠버 - 모델 EmbeddedHasManyArray 내가 간단한 송장 앱 엠버 모델을 사용하고
버그를 재현하려면 인보이스로 이동 한 다음 링크를 사용하여 다른 인보이스로 이동하고 멈추지 않는 것처럼 업데이트하지 않는 항목을보고 페이지를 새로 고침하면 올바른 항목을 얻을 수 있습니다. 잘못하고있다 : /? .. 기꺼이 도울 사람에게
감사
다음 코드는 물론 내 실제 응용 프로그램의 매우 단순화 된 버전이지만 버그를 재현한다.
Index.html을
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Ember - Starter" />
<meta charset=utf-8 />
<title>Ember-Model</title>
<script src="libs/jquery-1.9.1.js"></script>
<script src="libs/handlebars-1.0.0.js"></script>
<script src="libs/ember-1.1.2.js"></script>
<script src="libs/ember-model-latest.js"></script>
<script src="app.js"></script>
</head>
<body>
<script type="text/x-handlebars">
<h1>Invoices</h1>
{{ outlet }}
</script>
<script type="text/x-handlebars" data-template-name="factures">
{{#each}}
<ul>
<li>{{#link-to 'facture' this}}{{title}}{{/link-to}}</li>
</ul>
{{/each}}
<hr/>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="facture">
<h2>Items for {{title}}</h2>
{{#each items}}
<ul>
<li>{{desc}}</li>
</ul>
{{/each}}
</script>
</body>
</html>
App.js
var App = Ember.Application.create();
// ROUTER
App.Router.map(function() {
this.resource('factures', function() {
this.resource('facture', {
path: '/:facture_id'
});
});
});
App.FacturesRoute = Ember.Route.extend({
model: function (params) {
return App.Facture.find();
}
});
App.FactureRoute = Ember.Route.extend({
model: function (params) {
return App.Facture.fetch(params.facture_id).then(function (modelData) {
return App.Facture.find(params.facture_id);
});
}
});
// Redirect
App.IndexRoute = Ember.Route.extend({
redirect: function() {
this.transitionTo('factures');
}
});
// MODELS
var attr = Ember.attr,
hasMany = Ember.hasMany,
belongsTo = Ember.belongsTo;
// Factures
App.Facture = Ember.Model.extend({
title: attr(),
items: hasMany('App.Item', {
key: 'items',
embedded: true
})
});
App.Facture.adapter = Ember.FixtureAdapter.create();
// Facture
// -> [ Items ]
App.Item = Ember.Model.extend({
desc: attr(""),
qty: attr("number"),
price: attr("string")
});
// FIXTURES
App.Facture.FIXTURES = [
{
id: 1,
title: "Invoice #1",
items: [
{id: 1, desc: 'An Item for #1', qty: 2, price: "45"},
{id: 2, desc: 'An Item for #1', qty: 5, price: "75"}
]
},
{
id: 2,
title: "Invoice #2",
items: [
{id: 1, desc: 'An Item for #2', qty: 2, price: "250"},
{id: 2, desc: 'An Item for #2', qty: 5, price: "200"}
]
}];
덕분에 많이, 내가 솔루션이 될 것으로 보인다 얼마나 간단한 지 항상 놀란다, 또는 얼마나 바보 같은 내가 ... 내가 내 비품에있는 항목의 모든 ID를 설정하지 않는 시도하고 너무 작동 않습니다. 다시 한번 감사드립니다. – Wilhearts