user1226868
user1226868

Reputation: 1758

Ember JS and templating "Template not found"

So i have these script includes:

    <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>

This in my head tag:

        <script type="text/x-handlebars" data-template-name="application">
            WTF

        </script>

And this in my 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();

And i've totally lost the way. I just want to print "WTF" bewteen the . And do i need to include the script tag voor handlebars?

Upvotes: 1

Views: 463

Answers (1)

lcoq
lcoq

Reputation: 10726

First, you seems to use ember 1.0.0-pre2. So you don't have to specify Stocks.initialize() unless you set the autoinit Ember.Application property to false:

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

// omitted code

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

Next, you should include Handlebars before loading 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>

And it should work, as you can see in this JSFiddle.

Upvotes: 2

Related Questions