所以我有这些脚本包括:
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script src="js/vendor/ember-1.0.0-pre.2.min.js"></script>
<script src="js/vendor/handlebars-1.0.rc.1.js"></script>
<script src="http://yui.yahooapis.com/3.7.3/build/yui/yui-min.js"></script>
<script src="js/main.js"></script>
这是我头上的标签:
<script type="text/x-handlebars" data-template-name="application">
WTF
</script>
这在我的main.js中:
window.Stocks = Ember.Application.create();
Stocks.Router = Em.Router.extend({
initialState: 'root.home',
root: Em.Route.extend({
home: Em.Route.extend({
view: Stocks.CurrentStocksView
})
})
});
Stocks.CurrentStocksView = Ember.View.extend({
templateName: 'application',
appendTo: function() {
this._super('#current');
}
});
// Startup call
Stocks.initialize();
我完全迷失了方向。我只想打印“WTF”。我是否需要包含脚本标签voor handlebars?
答案 0 :(得分:2)
首先,您似乎使用ember 1.0.0-pre2
。因此,除非您将Stocks.initialize()
autoinit
属性设置为false,否则不必指定Ember.Application
:
Stocks = Ember.Application.create({
autoinit: false
});
// omitted code
Stocks.initialize(); // needed because the app is not automatically initialized
接下来,您应该在加载ember之前加入Handlebars
:
<script src="js/vendor/handlebars-1.0.rc.1.js"></script>
<script src="js/vendor/ember-1.0.0-pre.2.min.js"></script>
它应该有效,你可以看到in this JSFiddle。