モデルにあるすべてのレコードのコンポーネントを作成するテンプレートがあります。コンポーネントを見つけて、他のテンプレートからのイベントに基づいて実行時にそのプロパティの 1 つを更新したいと考えています。DOM に挿入された特定のコンポーネントを見つける方法。{{#each}} {{私の名前}} {{/each}}
<script type="text/x-handlebars" data-template-name="components/my-name">
Hi, my name is {{name}}.
</script>
var App = Ember.Application.create();
App.IndexRoute=Ember.Route.extend({
model:function(){
return dummyNames;
}
});
var dummyName={[name='John', name='Jane', name='Jade']};
このコードは、画面に名前を表示します。これで、change という別のテンプレートができました。
<script type="text/x-handlebars" data-template-name="change">
<button {{action 'changeNow'}}></button>
</script>
App.ChangeController=Ember.Controller.extend({
actions:{
changeNow:function(){
//Here I want to find the component where the name is Jane and change it to Kate. How to do this?
}
}
});