この例に従おうとしており (そして今は ember を 1.0rc2 に更新しています)、テンプレートをネストして開始したいと考えています。テンプレートに最初の追加{{outlet}}
があり、 2 つのネストされたビュー (1 つは「レジュメ」 、もう1 つはブートストラップ ファン向けの「ツールテーブル」)home
を含むようにしたいと考えています。「レジュメ」には再びネストされたテンプレートがありますが、この最初のレベルを乗り越えることができれば、他のこともできると思います。span9
span3
このSOによると?、および私の編集したJS Fiddle answer、それがどのように行われるかはちょっとわかりますが、答えはcoffeescriptにあり、例のルーターは私が理解できるよりも少し複雑です(connectOutlets
そのヘルパーの一部を使用してメソッド、私はそれ自体で理解しています。
最終結果は、この fiddleのようになります。
sections
しかし、ルーターとルーターは異なるパス上にあるため、他のテンプレートをホーム ルーターでレンダリングするにはどうすればよいでしょうかitems
。ただし、これらはインデックス ルートの一部になります/
。複数必要{{outlets}}
ですか? また、適切なテンプレートを適切なアウトレット プレースホルダーにルーティングするにはどうすればよいですか?
情報:
DEBUG: -------------------------------
DEBUG: Ember.VERSION : 1.0.0-rc.2
DEBUG: Handlebars.VERSION : 1.0.0-rc.3
DEBUG: jQuery.VERSION : 1.9.1
DEBUG: -------------------------------
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Resume Builder</title>
<meta name="description" content="A way to create a tailored resume from my CV" />
<meta name="author" content="Chris Frisina" />
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet" />
<link href="css/RB.css" rel="stylesheet" />
</head>
<body>
<script src="js/libs/jquery-1.7.1.js"></script>
<script src="js/libs/jquery.lorem.js"></script>
<script src="js/libs/bootstrap.min.js"></script>
<script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
<!-- // <script src="js/libs/ember1.js"></script> -->
<script src="js/libs/ember2.js"></script>
<script src="js/RB.js"></script>
<script type="text/x-handlebars" data-template-name="application">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<div class="brand home" {{bindAttr class="isHome:active"}} {{action "doHome"}}>Chris Frisina</div>
<div class="nav-collapse pull-right">
<ul class="nav">
<li class="sections"><a>1</a></li>
<li class="sections"><a>2</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="index">
<h3 class="demo-panel-title">This is the index template</h3>
{{home}}
</script>
<script type="text/x-handlebars" data-template-name="home">
<div class="row-fluid">
<!-- This is where I resume template should be placed -->
{{resume}}
<!-- This is where I tooltable template should be placed -->
{{tooltable}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="resume">
<div class="span9">
<h1>Viewer</h1>
</div>
</script>
<script type="text/x-handlebars" data-template-name="tooltable">
<div class="span3">
<div id="tooltable" class="tooltable hero-unit affix">
<h1>Tooltable</h1>
<p>Selector 1</p>
<p>Selector 1</p>
</div>
</div>
</script>
</body>
</html>
app.js :
// Attach the application to window
window.RB = Ember.Application.create({});
// Define the main application controller. This is automatically picked up by
// the application and initialized.
RB.ApplicationController = Ember.Controller.extend({
});
RB.ApplicationView = Ember.View.extend({
templateName: 'application'
});
// Router
RB.Router = Ember.Router.extend({
});
RB.Router.map(function(){
});
// Home
RB.HomeController = Ember.Controller.extend({
});
RB.HomeView = Ember.View.extend({
templateName: 'home',
});
// Resume
RB.ResumeController = Ember.ObjectController.extend({
});
RB.ResumeView = Ember.View.extend({
templateName: 'resume'
});
// Tooltable
RB.TooltableController = Ember.ObjectController.extend({
});
RB.TooltableView = Ember.View.extend({
templateName: 'tooltable'
});
//Defer the start until advanceReadiness() is complete
// cant init RB manually, must use advanceReadiness(), which needs defer...
RB.deferReadiness();
// var test = function() {
RB.advanceReadiness();
// });