名前付きアウトレットを使用して、テンプレートをアウトレットにレンダリングできます。私のアプリケーション テンプレートには、モーダルと呼ばれるアウトレットがあり、ApplicationRoute には openModal と closeModal という 2 つのアクションがあります。開いているものはテンプレート名を受け取り、ルート メソッド render を使用してアウトレット コンテンツを設定し、閉じるものは空のテンプレートをレンダリングします。
App.ApplicationRoute = Ember.Route.extend({
actions: {
openModal: function(modal) {
this.render(modal, {into:'application', outlet: 'modal'});
},
closeModal: function() {
this.render('empty', {into: 'application', outlet: 'modal'});
},
}
});
HTMLハンドルバー
<script type="text/x-handlebars" data-template-name="application">
{{! Other application template code}}
<button {{action openModal 'hellow.modal'}}>Open it!</button>
{{outlet modal}}
</script>
<script type="text/x-handlebars" data-template-name="empty"></script>
<script type="text/x-handlebars" data-template-name="hellow/modal">
<div class="modal">
<div class="modal-header">
Hellow
</div>
<div class="modal-footer">
<button {{action closeModal}}>Close</button>
</div>
</div>
</script>
これはhttp://nerdyworm.com/blog/2013/04/20/ember-modal-example/から改作されています