ember.js不起作用

时间:2014-11-16 23:03:03

标签: javascript html ember.js

我正在尝试使用ember.js,但它对我的html无效。我不知道为什么,但浏览器找不到模块车把。 HTML代码:

<body class="content" id="authorize">
      <script type='text/x-handlebars' data-template-name='application'>
        <div class='container'>
            {{outlet}}
        </div>
      </script>
        <script type='text/x-handlebars' data-template-name='teachers'>
            {{#each}}
                {{#link-to 'teacher' this}}
                    <div class="grid">
                        <img {{bind-attr src='photo'}} />
                        <h3>{{name}}</h3>
                        <p>{{subject}}</p>
                    </div>

                    <div>
                        <img src="./views/divider.png">
                    </div>
                {{/link-to}}
            {{/each}}
        </script>


        <script type='text/x-handlebars' data-template-name='teacher'>
            <div class="teacherinfo">
                <p>{{name}}</p>
                <p>{{subject}}</p>
                <img {{bind-attr src='photo'}}>
                <img src="views/button.png">
            </div>
        </script>
  </body>

和自定义js代码(ember):

(function(){
  var App=Ember.Application.create({
      LOG_TRANSITIONS: true
    });

    App.TEACHERS =[...];

    App.Router.map(function() {
  this.resource('teachers');
  this.resource('teacher', { path: '/teachers/:name' });
  });

    App.TeachersRoute = Ember.Route.extend({
  model: function() {
    return App.TEACHERS;
  }
});
App.TeacherRoute = Ember.Route.extend({
  model: function(params) {
    return App.TEACHERSfindBy('name', params.name); 
  }
});
})();

Firefox出现了这样的错误。

enter image description here

感谢您的关注和帮助:-)对于巨大的代码感到抱歉

1 个答案:

答案 0 :(得分:1)

Ember取决于jQuery和Handlebars。您可能没有在页面中包含Handlebars脚本。包括那个,错误应该消失。 Read the guide for more info.