1

所以我有这些脚本包括:

    <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();

我完全迷失了方向。我只想在 . 我是否需要包含脚本标签 voor 车把?

4

1 回答 1

2

首先,您似乎使用ember 1.0.0-pre2. Stocks.initialize()因此,除非您将autoinit Ember.Application属性设置为 false ,否则您不必指定:

Stocks = Ember.Application.create({
  autoinit: false
});

// omitted code

Stocks.initialize(); // needed because the app is not automatically initialized

接下来,您应该Handlebars在加载 ember 之前包含:

<script src="js/vendor/handlebars-1.0.rc.1.js"></script>
<script src="js/vendor/ember-1.0.0-pre.2.min.js"></script>

正如您在此 JSFiddle中所见,它应该可以工作。

于 2012-10-30T12:39:51.860 回答